VMware Cloud Community
shaggy_041086
Enthusiast
Enthusiast
Jump to solution

How to do REST calls on vRO 7.3

Hi all,

I am new to REST so please bear with me. I have a workflow in vRO to check DEAD LUNs on my host HBAs and it sends an email report if it finds one. The workflow has only one input, i.e. "email id".

When I try to execute the workflow in swagger page of vRO with following input -

"parameters": [
    {
        "value": {
            "string": {
                "value": "XYZ@blahblah.com"
            }
        },
        "type": "string",
        "name": "toAddress",
        "scope": "local"
    }
]

, it says "400 – Bad Request : The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)". But when I do GET commands, like GET all workflows and EXECUTIONS, it works fine.

I even tried Postman and it also works with Basic authentication, but only GET commands. It throws same error as above when trying POST. Tried using Oauth 2.0 in Postman as mentioned here. But not able to get the {{client-id}} info that is required there.

Now I am trying to execute the POST command through Powershell, but since vRO uses holder-of-key (HoK) token system to get me authenticated through SSO, I am not sure basic authentication would work or how to go about using that kind of authentication.

Anyone had similar issues? Fixes? Recommendations?

What client do you all use to do REST calls to vRO? This particular post says POST method is possible through basic authentication, but is not working for me. I have used admin credentials to vRO and have confirmed I have admin rights.

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

I suppose you forgot to change the value of the Swagger UI dropdown labelled "Parameter content type" from its default value 'application/xml' to 'application/json'.

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

View solution in original post

Reply
0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

The input you are passing is not a valid JSON and that's why you are getting error 400. To fix it, just add a pair of curly brackets around it.

{

  "parameters": [

    {

        "value": {

            "string": {

                "value": "XYZ@blahblah.com"

            }

        },

        "type": "string",

        "name": "toAddress",

        "scope": "local"

    }

  ]

}

shaggy_041086
Enthusiast
Enthusiast
Jump to solution

I am sorry I did use the braces at start and at the end. It got omitted when posting in this thread.

Reply
0 Kudos
shaggy_041086
Enthusiast
Enthusiast
Jump to solution

Quick update -

I was able to execute the workflow in Postman and I was indeed missing the first and last braces there. After success, have tried curl in windows and that works as well. Thanks to this post. But still the swagger page doesn't go past error 400. Any clues why?

As far as powershell is concerned, I came across two options -

1. Use PowervRO cmdlets from powershell gallery as described here

2. Construct .NET based REST functions and run as described here

Will try them and keep you'll posted. If someone can help me fix the swagger issue, I can mark this thread answered!

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

I suppose you forgot to change the value of the Swagger UI dropdown labelled "Parameter content type" from its default value 'application/xml' to 'application/json'.

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

Reply
0 Kudos
shaggy_041086
Enthusiast
Enthusiast
Jump to solution

Thanks iiliev​! That was the issue. It works now.

I also did try both of the solutions posted above for PowerShell and they work flawlessly too!

Reply
0 Kudos