How to call scripted rest api in workflow

Rama26
Tera Contributor

Hi,

I created scripted rest api and provided endpoint to 3rd party.. how can I call scripted rest api in workflow.  Once the response is success then only workflow process further

 

5 REPLIES 5

Tony Chatfield1
Kilo Patron

Hi, without any details of your configuration, the forum cannot assess your issue.
Perhaps you could update this thread to include details of your code including the way the REST API is called and how you deal with the result, also a clear end to end description of your process would provide some context to your issue.

HI Tony,

i received data from 3rd party in JSON format. once they send data using this endpoint, automatically RITM submitted(using cart) and the response like below

response = {
data: [{
status: "Success",
statusMessage: "RITM Created for new service"
}]
};
return response;
} else {
response = {
data: [{
status: "Failure",
statusMessage: "some variables empty so unable to proceed request"
}]
};
return response;

 

How can i call success response in wait for condition. because based on success response only workflow will proceed further. 

I would try using a workflow scratchpad variable,
Set the variable true (success) or false(failure) from your REST response in your script activity
Then reference the variable in a 'Wait for condition' activities script.

https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/administer/using-workflows/concept/c_UsingVariablesInAWorkflow.html#conceptey1dsqbp

based on field true in wait for condition it will work. but how can i get response in workflow.

because if i receive response in workflow then only i can differentiate whether it's success or fail