Form-data in Request Method

The Request API can be used for form-data requests and the content-type used is: application/x-www-form-urlencoded.

Sample request:

config/requests.json

{
  "examplePostCall": {
    "schema": {
      "method": "POST",
      "host": "example.com",
      "path": "/form",
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    },
    "options": {}
  }
}

manifest.json

{
  "platform-version": "2.3",
  "product": {
    "freshdesk": {
      "location": {
        "ticket_sidebar": {
          "url": "index.html",
          "icon": "styles/images/icon.svg"
        }
      },
      "requests": {
        "examplePostCall": {}
      }
    }
  },
  "engines": {
    "node": "18.16.1",
    "fdk": "9.0.3"
  }
}

app/scripts/app.js

async function foo() {
  let body = {
    form: {
      name: "Tony Stark",
      age: 50,
      occupation: ["CEO", "Consultant", "Benefactor", "Mentor"],
    },
  };
  await client.invokeTemplate("examplePostCall", {body});
}