IT Process Automation

  • 1.  How to Use REST with JSON to start a process with arguments?

    Posted Nov 02, 2016 06:26 PM

    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"}
    ]
    }
    }



  • 2.  Re: How to Use REST with JSON to start a process with arguments?

    Posted Nov 02, 2016 06:30 PM

    Oh,   and if I only want to pass one variable this works:

     

    {
    "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"}
    }
    }
    }



  • 3.  Re: How to Use REST with JSON to start a process with arguments?

    Broadcom Employee
    Posted Nov 03, 2016 08:41 AM

    Have you tried a combination of your first two?  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"
    },
    "Arguments": [
    Argument: {"Name": "Myarg1", "Value": "MyData1"},
    Argument: {"Name": "Myarg2", "Value": "MyData2"},
    Argument: {"Name": "Myarg3", "Value": "MyData3"}
    ]
    }
    }



  • 4.  Re: How to Use REST with JSON to start a process with arguments?

    Posted Nov 04, 2016 09:52 AM

    Logically you'd think I would have but I didn't.  After trying it, It also doesn't work.  however, this did so looks like I'm good now.  Thx.

     

     

    {
    "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"},
      {"Name": "Myarg2", "Value": "MyData2"},
      {"Name": "Myarg3", "Value": "MyData3"}
    ]
    }
    }
    }