- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 02:48 AM
Hi,
How to pass this JSON request in query parameters of REST API
"comment": { "body": "The smoke is very colorful." },
Thank you.
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 03:57 AM
Hi Harish,
http://wiki.servicenow.com/index.php?title=RESTMessageV2_API#setRequestBody.28String_body.29
You can use setRequestBody method for setting this "request body"
eg,
setRequestBody(JSON.stringify(myObj));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 02:50 AM
Hi Harish,
it seems this request you want to send in the body of the request. you could use content body for POST or PUT method.
What is the exact requirement?
You can give query parameters in the GET method.
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
08-26-2017 02:59 AM
Hi Ankur,
Thanks for responding, Yes I am passing the below JSON request in content of REST API,
{
"ticket": {
"subject": "New Ticket is created!",
"comment": { "body": "Urgent incident needs to be fixed ASAP" },
"priority": "urgent"
}
}
Now I needs to put this in business rule for sending tickets to outbound.
How can I put this in Business rule as this is in JSON format. JSON Request starts with ticket and next its fields.
"comments" : {"BODY" : XXXXX } will change dynamically based on what user fill in short description.
can you please help me how to put this in business rule
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 03:25 AM
Hi Harish,
I believe you want to send short_description of the current record, then you can try something like below
var myObj =
{
"ticket": {
"subject": "New Ticket is created!",
"comment": { "body": current.getValue('short_description')}, // set value of the short description to body property of comments.
"priority": "urgent"
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017 03:45 AM
Hi Deepak,
This JSON format contains one or more arrays, Now I have to send this JSON format in rest request body (NOT in RESPONSE BODY) to third party application to create incident in their application.
var myObj =
{
"ticket": {
"subject": "New Ticket is created!",
"comment": { "body": current.getValue('short_description')}, // set value of the short description to body property of comments.
"priority": "urgent"
}
};
Thank you.