Unable to parse JSON for a field in REST message using setRequestBody method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 07:53 AM
We are unable set parameters in request Body.
error message:
logs are printing fine.
value of body input_data={"request":{"subject":"Product Notice: The status of MOTORCYCLEACCIDENT.COM has changed.","description":"Product Notice: The status of MOTORCYCLEACCIDENT.COM has changed.\n\nYou can see this change in your account or get more details inside. \n\n
rest message function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 08:28 AM - edited 07-10-2025 08:29 AM
Hello @GD11
The value of body input_data is in JSON format, hence you should update this:
r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
to this:
r.setRequestHeader("Content-Type", "application/json");
and then replace this:
var inputData = "input_data="+ JSON.stringify(requestObj);
to this:
var inputData = JSON.stringify(requestObj);
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 08:53 AM
can you share what you have configured in REST Message method in Content body?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 09:18 AM
Hi @Ankur Bawiskar and @Vishal Jaswal i tried suggestion of vishal and it is giving different error now.
error: value of response body {"response_status":{"status_code":4000,"messages":[{"status_code":4001,"field":"input_data","type":"failed","message":"Value not present for input_data"}],"status":"failed"}}
sharing rest message method configuration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 09:20 AM
Hi @Ankur Bawiskar and @Vishal Jaswal i tried suggestion of vishal and it is giving different error now.
error: value of response body {"response_status":{"status_code":4000,"messages":[{"status_code":4001,"field":"input_data","type":"failed","message":"Value not present for input_data"}],"status":"failed"}}
sharing rest message method configuration.