Sending XML format using POST method to send data from ServiceNow Through Flow Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @fasiham13180808 ,
I tested this using two separate serviceNow instances. In the first instance , I implemented a Flow designer action with REST Step to send the XML Payload using the POST method. I used a Connection Alias to connect to the second serviceNow instance and configured the appropriate resourse path.
In the second instance, I created the scripted REST API with POST resource to receive the XML. The incoming XML is accessed using request.body.dataString, and I check the response is coming or not by using log messages.
scripted REST Resource
(function process(request,response){
var xmlBody = request.body.dataString;
gs.info(‘xmlBody’+xmlBody);
responses.setStatus(200);
return{
status : ”success”,
message : ”XML received success”,
received_xml : xmlBody
};
})(request,response);
I tested the flow it returns the response success with HTTP 200. and i also verified in system logs in the receiving instance it comes XML payload which was sent using POST method using REST Step.
I didn't leave the resourse path empty i use both base url and resourse path i specified the receiving scripted REST api resource path.
In the payload i used the
Method : POST ,
Headers Content-Type : application/xml,
Request type : Text,
and passed the XML directly in the request body on the receiving Scripted REST api, I read it using request.body.dataString.
