How to call scripted rest api in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 09:36 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 09:41 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 10:28 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 10:52 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2022 12:05 AM
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