Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Sending XML format using POST method to send data from ServiceNow Through Flow Action

fasiham13180808
Tera Contributor
Hello,
I am setting up an outbound integration to send data to an external provider via a custom Flow Designer Action. 
Has anyone successfully configured through an Flow Designer REST step before?
Did you run into any issues leaving the resource path blank, or did you have to handle the payload format in a specific way to get the endpoint to accept it? Any feedback or shared experiences would be highly appreciated!
Thanks!
1 REPLY 1

pavanpadaga
Mega Contributor

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.

pavanpadaga_2-1787999848521.png

 



 

pavanpadaga_1-1787999489221.png

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.

pavanpadaga_3-1788000809173.png


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.