- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 07:52 AM
Hi Community,
As per our client requirement, I am trying to assign dynamic data as key value pairs in response body through scripted REST API. But I am getting error in REST API Explorer. Please find below screenshots for reference.
Any help would be appreciated!
Scripted REST API function:
calling this function in scripted API only:
Error in REST API Explorer:
POST test throgh REST exp - is the short description of the incident.
Here the problem is to assign the key dynamically to the response object.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 08:25 AM
Hi,
update line as this and it should work fine
obj[respFields[i]] = gr.getValue(respFields[i]);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
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
‎06-08-2022 08:25 AM
Hi,
update line as this and it should work fine
obj[respFields[i]] = gr.getValue(respFields[i]);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader