- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 07:00 AM
Hello everyone,
when I try to access the request body of an HTTP request generated by Postman, I get the following error:
I don't understand this. I'm not using GET here, I use POST. The resource I created on my API on Snow also uses POST.
I also pass values in the request body, that's why I need to access it. Content type is application/x-www-form-urlencoded which is also supported by my resource in Snow.
The second line causes the error:
Can someone please help me?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 07:21 PM
Hi,
I believe for Content Type as application/x-www-form-urlencoded it transfers data in url as key value pair and not as body
check below links they might be helpful:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
https://github.com/github/fetch/issues/263
https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
simple example below
application/x-www-form-urlencoded - this tells the web server that you will be encoding the parameters in the URL as in
short_description=Testing&comments=testing+comments
application/json - this tells the web server that you are posting JSON data as in
{"short_description":"Testing","comments":"testing comments"}
possibly you need to use this to get the URL; print in logs and check
request.pathParams or request.queryString
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 07:21 PM
Hi,
I believe for Content Type as application/x-www-form-urlencoded it transfers data in url as key value pair and not as body
check below links they might be helpful:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
https://github.com/github/fetch/issues/263
https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
simple example below
application/x-www-form-urlencoded - this tells the web server that you will be encoding the parameters in the URL as in
short_description=Testing&comments=testing+comments
application/json - this tells the web server that you are posting JSON data as in
{"short_description":"Testing","comments":"testing comments"}
possibly you need to use this to get the URL; print in logs and check
request.pathParams or request.queryString
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 04:43 AM
All right, this makes sense. x-www-form-urlencoded posts the parameters in the URL.
But still, it doens't make sense that I cannot access the request body.
Anyway, I solved it using application/json, because this worked. Thanks for your help! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2023 04:53 AM
Hello Mega,
Did you find a solution for this case we have the same issue.