API Response: , HTTP Status: 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 09:19 PM
i am using the below code to send to my flask api but i am seeing the message is not getting posted as the HTTPstatus code is 0 .
my flask api is working fine as i am able to post from python script and its exception response
Can anyone please help me with whats wrong in my below js code.
using gs.info i can see the incident number and short description is getting fetched when workflow is triggered.
(function executeRule(current, previous /*null when async*/ ) {
try {
var incidentNumber = current.getValue('number');
var shortDescription = current.getValue('short_description');
var payload = {
incident_number: incidentNumber,
short_description: shortDescription
};
// var apiEndpoint = 'http://172.187.194.224/servicenowwebhook';
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('post');
request.setEndpoint('http://my_flask_api_url/service-now-webhook');
// request.setRequestHeader('Content-Type', 'application/json');
request.setRequestBody(JSON.stringify(payload));
response = request.execute();
responseBody = response.getBody();
httpStatus = response.getStatusCode();
gs.info('API Response: ' + responseBody + ', HTTP Status: ' + httpStatus);
} catch (e) {
gs.error('Error in Business rule: ' + e.message);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 08:43 AM
Did you figured out the issue?