Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Save Workflow Action using REST API

SathyaPriyan_
Contributor III

I have tried to click workflow action button using REST API call with below code from browser console. but it is throwing 405 error(method not allowed) or 403 error(forbidden) when I tried with different verb PUT.

If I try to click the button from REST API console in Archer API template application, then REST API call with POST verb is getting successful.

var xhr = new XMLHttpRequest();
var json_body = {
"ContentId": 123456,
"CompletionCode": 1
"WorkflowNodeId": "12345:CUST"
}
json_body = JSON.stringify(json_body);
xhr = new XMLHttpRequest();
xhr.open('POST',""+BaseURL +"/api/core/system/WorkflowAction", true);
xhr.setRequestHeader("Accept", "*/*");
xhr.setRequestHeader("Authorization", "Archer session-id="+ session);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(json_body));
xhr.onreadystatechange = function ()
{
if(xhr.readyState == 4)
{
console.log("Processing Request");
if(xhr.status==200)
{
console.log("Workflow button is clicked");
}
else
{
console.log(xhr.status);
}
}
}

Is there something that I missed in the REST API call?

15 REPLIES 15

I blurred that part in my previous screenshot. Please look at this original one

SathyaPriyan__0-1683827363894.png

 

Thanks, I missed that part in your other post ; (

Try sending this as a header:

'x-csrf-token': (window.sessionStorage) ? window.sessionStorage.getItem("x-csrf-token") : parent.parent.ArcherApp.globals['xCsrfToken']

 Advisory Consultant

Hi David,

I was able to push a single record to the next node in AWF using the POST /api/core/system/WorkflowAction using the JSON body 

{
  "ContentId"709365,
  "CompletionCode"1,
  "WorkflowNodeId""1229732:CUST"
}
Is there a different format to include multiple Content IDs to advance multiple records through AWF with the same method?

@bohljeff unfortunately, the API only takes one Content ID at a time.

 Advisory Consultant

@DavidPetty Thank you, It is working when I pass X - CSRF session token to the header. May I know why it was not working when I passed user session token to the header in my POST request?

It's for CSRF protection.

 Advisory Consultant