logo

NJP

Control request and response content type x-www-form-urlencoded

Import · Oct 26, 2023 · article

x-www-form-urlencoded is not a standard content type for data transmission. You might be referring to application/x-www-form-urlencoded, which is a common content type used when submitting data through HTML forms on the web. It is a way of encoding key-value pairs as a string in the format of key1=value1&key2=value2.

I was doing integration with PRTG, the idea was to get the alerts and create incident in ServiceNow. However while creating web-hook comes with the this particular content type. You can try to use it as follows :

  • Create scripted rest api :

Screenshot 2023-10-26 at 4.34.10 PM.png

Override default supported request formats as : application/x-www-form-urlencoded

Scripted resource as follows :

Screenshot 2023-10-26 at 4.35.56 PM.png

we can retrieve the urlencoded values provided in the request as a JSON map. You can then supply these urlencoded key-value pairs as query parameters, in the request body, or both. They are combined and stored in the request parameters. Access these parameters through the request.queryParams object.

Testing : Tool used Postman

Screenshot 2023-10-26 at 4.38.23 PM.png

We are getting 200 ok. You can add log messages in order to see the response.

View original source

https://www.servicenow.com/community/itom-articles/control-request-and-response-content-type-x-www-form-urlencoded/ta-p/2714234