AnsweredAssumed Answered

How to Use REST with JSON to start a process with arguments?

Question asked by Brett_Zipkin on Nov 2, 2016
Latest reply on Nov 4, 2016 by Brett_Zipkin

Will be integrating with an outside vendor who will be sending REST requests via JSON.  Trying it internally first so I can give them guidance.

 

What I want to do is start a process and pass 2 or more variables into the process using JSON.  I can do it via XML but having difficulty with the proper syntax for JSON.  Can anyone tell me where I'm going wrong on the bottom 2 examples?

 

Using POST on http://{ServerName}:7000/node/rest/CA:00074_CA:00074:01/_ops/Start

 

This works in XML

<StartRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p1:StartRequest" xmlns:p1="http://ns.ca.com/2011/09/pam-ops" >
<EntityID>
<MdrElementID>/Testing/Test process</MdrElementID>
</EntityID>
<Arguments>
<Argument>
<Name>Myarg1</Name>
<Value>MyData1</Value>
</Argument>
<Argument>
<Name>Myarg2</Name>
<Value>MyData2</Value>
</Argument>
<Argument>
<Name>Myarg3</Name>
<Value>MyData3</Value>
</Argument>
</Arguments>
</StartRequest>

 

 

Using JSON I can start a process successfully with no arguments like this.

{
"StartRequest": {
"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance",
"@xsi:type":"p1:StartRequest",
"@xmlns:p1":"http://ns.ca.com/2011/09/pam-ops",
"EntityID": {
"MdrElementID": "/Testing/Test process"
}
}
}

 

Using the above 2 success as a guide I tried these 2 alternates...

This results error 'Duplicate key "Argument" ' 

{
"StartRequest": {
"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance",
"@xsi:type":"p1:StartRequest",
"@xmlns:p1":"http://ns.ca.com/2011/09/pam-ops",
"EntityID": {
"MdrElementID": "/Testing/Test process"
},
"Arguments": {
"Argument": {"Name": "Myarg1", "Value": "MyData1"},
"Argument": {"Name": "Myarg2", "Value": "MyData2"},
"Argument": {"Name": "Myarg3", "Value": "MyData3"}
}
}
}

 

Using the [ ] method for a list, This resuls with error " Feature 'Name' not found "

{
"StartRequest": {
"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance",
"@xsi:type":"p1:StartRequest",
"@xmlns:p1":"http://ns.ca.com/2011/09/pam-ops",
"EntityID": {
"MdrElementID": "/Testing/Test process"
},
"Arguments": [
{"Name": "Myarg1", "Value": "MyData1"},
{"Name": "Myarg2", "Value": "MyData2"},
{"Name": "Myarg3", "Value": "MyData3"}
]
}
}

Outcomes