Active IQ Unified Manager Discussions

New to REST and WFA (4.1) -- issues with calling workflows with POST or DELETE

SuperMegaGreat
3,030 Views

Hi all,

 

I've been googling, reading random posts on this forum and pouring over examples in:

https://MYWFAHOST/rest/docs/#!/Execution%3AWorkflows/executeWorkflow

 

I've been able to make GET calls works, but am yet to make a POST/PUT/DELETE do anything helpful.

I starteed with a hugely basic workflow in an effort get passing things via REST down pat.  I've kept everythign in CURL, as that is what the examples noted above use and i'm wanting things to be easy.

 

For those where i currently am, here is a basic run down of what i know so far.

there are lots of ways to authenticate, but while learing BASIC is the one you should stick with.  its super easy.

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" -X GET https://WFAserver:443/rest/workflows

the -k ignores SSH keys

the -u allows you to provide initial challange authentication

the --header is where you call out XML or JSON

the -X is where you specify GET/POST/PUT/DELETE

all of this is followed by the URI

 

This also works with out issue:

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" -X GET https://WFAserver:443/rest/workflows?name=testIgroup

 

 

Easy right?  Thats what i thought too.  The above work every time with out issue.

 

So when i tried to preform a POST to create an empty iGroup, my workflow has all the things in it to work and DOES work from the gui.  Tthe only user input is "hostName", in an effor to make this as easy as possible.  Under the advanced tab, i set the custom URI to "/testIgroup"  In theory, it would be as hard as calling this:

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" --header "Accept: text/plain" -d '<?xml version="1.0" encoding="UTF-8"?><workflowInput><userInputValues><userInputEntry key="hostName" value="TESTTESTTEST"/></userInputValues></workflowInput>' -X POST https://WFAserver:443/rest/testIgroup/jobs

the -k ignores SSH keys

the -u allows you to provide initial challange authentication

the --header is where you call out XML or JSON and Accept type per the examples in the docs

the -X is where you specify GET/POST/PUT/DELETE

the -d is where you put your data payload, in this case an XML sting

'<?xml version="1.0" encoding="UTF-8"?>

<workflowInput>

<userInputValues>

<userInputEntry key="hostName" value="TESTTESTTEST"/>

</userInputValues>

</workflowInput>'

all of this is followed by the URI

 

i get this:

No resource method found for POST, return 405 with Allow header

 

I then tried using a DELETE method from a post i read from "sinhaa".  I changed the type to DELETE and put /{hostName}/testIgroup in the custom URI area under the advanced tab.

then attempted to call it with this:

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" -X DELETE https://WFAserver:443/rest/TESTtestTEST/testIgroup

I was hopeful, but this also didn't work for me.

No resource method found for DELETE, return 405 with Allow header

 

 

 

So.  I'm going in circles trying to figure this out and am now giving up and asking for help.

A) what exactally is a "workflow_exectuion_id"

B) what is a "workflow_uuid"

C) what on earth am i doing wrong?

 

 

Thanks in advance!

1 ACCEPTED SOLUTION

SuperMegaGreat
3,010 Views

Well...

 

In explaing how I am right and WFA is wrong, i answered my own question.

 

WTF you ask? 

Heh. 

I will show you the mistake i made using my example from earlier. 

Diffrences that made it work are now in RED.

 

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" --header "Accept: text/plain" -d '<?xml version="1.0" encoding="UTF-8"?><workflowInput><userInputValues><userInputEntry key="hostName" value="TESTTESTTEST"/></userInputEntry></userInputValues></workflowInput>' -X POST https://WFAserver:443/rest/testIgroup/jobs

the -k ignores SSH keys

the -u allows you to provide initial challange authentication

the --header is where you call out XML or JSON and Accept type per the examples in the docs

the -X is where you specify GET/POST/PUT/DELETE

the -d is where you put your data payload, in this case an XML sting

'<?xml version="1.0" encoding="UTF-8"?>

<workflowInput>

<userInputValues>

<userInputEntry key="hostName" value="TESTTESTTEST"/> ### Oops, this needs to be removed

</userInputEntry> ### Oops, i didn't close my user input tag

</userInputValues>

</workflowInput>'

all of this is followed by the URI

 

Corrected CURL

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" --header "Accept: text/plain" -d '<?xml version="1.0" encoding="UTF-8"?><workflowInput><userInputValues><userInputEntry key="hostName" value="TESTTESTTEST"></userInputEntry></userInputValues></workflowInput>' -X POST https://WFAserver:443/rest/testIgroup/jobs

 

For posterity, it now returns a pile of things.  One of which is the jobId number.

jobId="####"

 

Once you have this job ID, you can then loop looking for the jobstatus

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" -X GET https://WFAserver:443/rest/rest/workflows/jobs/####

There is a lot of data returned, but this is what i was looking for

<jobStatus>SCHEDULED</jobStatus><jobType>Workflow Execution -

<jobStatus>EXECUTING</jobStatus><jobType>Workflow Execution - ....

<jobStatus>FAILED</jobStatus><errorMessage>Failed to connect to cluster node: ...(i disconnected my arrays on purpose so i can test w/o worry)

 

View solution in original post

1 REPLY 1

SuperMegaGreat
3,011 Views

Well...

 

In explaing how I am right and WFA is wrong, i answered my own question.

 

WTF you ask? 

Heh. 

I will show you the mistake i made using my example from earlier. 

Diffrences that made it work are now in RED.

 

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" --header "Accept: text/plain" -d '<?xml version="1.0" encoding="UTF-8"?><workflowInput><userInputValues><userInputEntry key="hostName" value="TESTTESTTEST"/></userInputEntry></userInputValues></workflowInput>' -X POST https://WFAserver:443/rest/testIgroup/jobs

the -k ignores SSH keys

the -u allows you to provide initial challange authentication

the --header is where you call out XML or JSON and Accept type per the examples in the docs

the -X is where you specify GET/POST/PUT/DELETE

the -d is where you put your data payload, in this case an XML sting

'<?xml version="1.0" encoding="UTF-8"?>

<workflowInput>

<userInputValues>

<userInputEntry key="hostName" value="TESTTESTTEST"/> ### Oops, this needs to be removed

</userInputEntry> ### Oops, i didn't close my user input tag

</userInputValues>

</workflowInput>'

all of this is followed by the URI

 

Corrected CURL

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" --header "Accept: text/plain" -d '<?xml version="1.0" encoding="UTF-8"?><workflowInput><userInputValues><userInputEntry key="hostName" value="TESTTESTTEST"></userInputEntry></userInputValues></workflowInput>' -X POST https://WFAserver:443/rest/testIgroup/jobs

 

For posterity, it now returns a pile of things.  One of which is the jobId number.

jobId="####"

 

Once you have this job ID, you can then loop looking for the jobstatus

curl -k -u USERNAME:PASS --header "Content-Type: application/xml" -X GET https://WFAserver:443/rest/rest/workflows/jobs/####

There is a lot of data returned, but this is what i was looking for

<jobStatus>SCHEDULED</jobStatus><jobType>Workflow Execution -

<jobStatus>EXECUTING</jobStatus><jobType>Workflow Execution - ....

<jobStatus>FAILED</jobStatus><errorMessage>Failed to connect to cluster node: ...(i disconnected my arrays on purpose so i can test w/o worry)

 

Public