Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here you see an example of a GET request med made via the REST API app:

...

An example of a POST request, with data being sent via the “data” field:

...

Info

Regarding default headers:

If no “Content-Type” header is provided in the request, the backend will set it by default to “application/json”, except for GET requests which will instead have an “Accept” header set to “application/json” by default.

Info

Regarding URL encoded requests:

If you are using header “Content-Type” set to "application/x-www-form-urlencoded" then the “data” field can be used to send the parameters. The entries in “data” are expected to have “Name” and “Value” fields, which will be used to set the parameters for the outgoing request.

Full list of available fields for the request object:

Code Block
languagejs
    let request = {
      "verb": "POST", //currently supported HTTP verbs are GET, POST, PUT, PATCH, and DELETE
      "requestUrl": "/myendpoint" //only the last part (i.e. the endpoint) is needed here, as the base url comes from the app you registered
      "parseResponse": true, //try to automatically parse the response as json, xml, or csv
      "responseCodes": [200], //expected response codes, which will not trigger an exception
      "headers": [
          { "key" : "Accept", "value" : "application/json" }, 
          { "key" : "Content-Type", "value" : "application/vnd.api+json" }],
      "cookies": [
          { "key" : "CookieName1", "value" : "CookieValue1" }, 
          { "key" : "CookieName2", "value" : "CookieValue2" }],
      "data": {"myField": myValue }, //the data to send, as request body
      "csvHeaders": false,
      "csvSeparator": ";",
      "csvResponse": false,
      "removeXMLBOM": false,
      "returnCookies": false, //include the cookie in the response
      "encoding": "UTF8",
      "baseURL": //not in use, as the base URL comes from the stored app credentials
      "successCode": 200
    }

Parameters for the ‘rest/request’ endpoint:

Code Block
languagejs
await api.post('rest/request', request, trustCertificate, isoFormatJsonDates)
  • “request” is the request object, as described above

  • “trustCertificate” is a boolean which can be used to ignore SSL certificate errors. Defaults to false.

  • “isoFormatJsonDates” is a boolean which can be used to ensure that date formatted strings are not parsed to a date type, but are instead read as strings. Defaults to true.