Web Service JSON creating blank incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 05:59 AM
Hi All,
I am using Web Service to pass incident from one instance A to another instance B. In source A I am using Outbound --> REST Message. Which has got HTTP Request with Accept & Content-Type and value as json. And four HTTP Methods are also defined & these are Delete, post, put & get. In Source Instance A, i have created a UI action and calling the script action based on that event. Below are the line of codes, which is creating incident in Target Instance B but with blank and I would like to pass few values from instance A to instance while posting new ticket and these are state, short description, description, Caller etc.
In Instance B, I have created System Web Service--> Inbound. However in Web Service Transform Maps there is no field mapping yet. Do i need to define between staging table's field and destination table's field?
In Script action below is code:-
createticket();
function createticket()
{
function jsonEncode(str) {
str = new JSON().encode(str);
return str.substring(1, str.length - 1);
}
json.state = current.state;
json.short_description = current.short_description;
json.description = current.description;
json.u_caller = current.u_raised_by; // In Instance B caller is called as Raised By
try {
var r = new sn_ws.RESTMessageV2('Fruition API', 'post');
r.setStringParameter("short_description",current.short_description);
r.setStringParameter("state",current.state);
r.setStringParameter("description",current.description + '');
r.setStringParameter("u_caller",current.u_raised_by);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('Response Body :' + responseBody);
}
catch(ex) {
var message = ex.getMessage();
}
}
In Log Response Body is printing:-
Response Body :{"result":{"number":"INC003813","close_notes":"","service_offering":"","u_total_hours_worked":"","u_project":"","additional_assignee_list":"","impact":"3","urgency":"3","correlation_id":"","u_business_service":"","u_update_flag":"true","description":"","state":"-6",,"short_description":"",,"comments_and_work_notes":","sys_created_on":"2016-09-30 10:15:11","reassignment_count":"0","u_symptom":"","u_estimated_cost":"0","opened_at":"2016-09-30,"sys_created_by":"abcd""}}
And in Source Instance A, in HTTP method Post, I have added Number and value as ${number} under section HTTP Query Parameters. And clicked on Test. It brings new incident number from instance B. And getting HTTP status as 201 However, when i have added one more parameter Short Description to it and Test that. Status code is returning 500
Error executing REST request: Invalid uri 'https://instanceb.service-now.com/api/now/table/incident?Number=&Short Description=': Invalid query
Could anyone of you please let me know what & where I would need to correct? Quick response must be appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2019 05:58 AM
Hi Manish,
I'm working on the similar requirement. Can you please let me know the business rule you have used for update operation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 08:35 AM
I mean to ask whether do i need to do some change in HTTP Request to include anything special for Attachment. Currently, I have setup Accept & Content-Type and values are set to application/json. Or do i need to add anything on script include where I have written my POST and GET script?