VMware Cloud Community
asnodgrass
Contributor
Contributor
Jump to solution

JSON usage with vCO 5.1 REST API

I'm trying to develop a simple REST client to execute a workflow in vCO.  I'm using perl and the REST::Client module, which is pretty straight forward.  I can retrieve the inventory and definition objects for my target workflow, but when I try to POST an execution, I get an error report back stating:

The request sent by the client was syntactically incorrect ().

I am using JSON (as that is both the default output from vCO if no Content-Type is specified and my personal preference), and the documentation on JSON formatting is quite sparse compared to the supplied XML documentation.  The docs describe the execution-context as follows:

{ "parameters" : [ { "name" : "...", "type" : "...", "description" : "...", "scope" : "local", "value" : { } }, ... ] }

My workflow accepts two string parameters for input and returns one string parameter as output.  I've read that the scope and description fields are optional, and I am omitting both.  Clearly however, I am missing something necessary about the structure of the execution-context.  Can anyone help shed some light on this?

Full debugging:

Accept: application/json
Accept-Encoding: gzip, x-gzip, deflate, x-bzip2
Authorization: *******
User-Agent: REST::Client/249
Content-Length: 137
Content-Type: application/json
{"parameters":[{"value":"10.0.0.0/24","name":"network","type":"string"},{"value":"test-hostname.dom","name":"hostname","type":"string"}]}

HTTP/1.1 400 Bad Request
Connection: close
Date: Wed, 05 Dec 2012 19:01:11 GMT
Server: vCO Server
Content-Length: 965
Content-Type: text/html;charset=utf-8
Client-Date: Wed, 05 Dec 2012 19:06:21 GMT
Client-Peer: ******:8281
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=VMware/OU=VMware/CN=localhost.localdom
Client-SSL-Cert-Subject: /C=US/O=VMware/OU=VMware/CN=localhost.localdom
Client-SSL-Cipher: DHE-RSA-AES256-SHA
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Title: JBossWeb/2.0.1.GA - Error report


<html><head><title>JBossWeb/2.0.1.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The request sent by the client was syntactically incorrect ().</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.1.GA</h3></body></html>

0 Kudos
1 Solution

Accepted Solutions
igaydajiev
VMware Employee
VMware Employee
Jump to solution

There was an issue with the deserialization of the value from JSON format, it is fixed and will be available in 5.1 U1 release.

View solution in original post

0 Kudos
5 Replies
BillSkulley
Contributor
Contributor
Jump to solution

This is a total shot in the dark, because I don't know JSON, but the returns I get from XML gets on previous executions of workflows return string parameters similiar to this:

{"parameters":[{"name":"network","value":{"value":"10.0.0.0/24", "objectType":"string" }, "type":"string" },{"name":"hostname","value" { "value":"test-hostname.dom", "objectType":"string" }, "type":"string" }]}

I suspect the real issue is the format of value is "value":{....} but again... I don't know JSON.

HTH

BillSkulley
Contributor
Contributor
Jump to solution

Just noticed a critical typo in my reply, dropped a colon... corrected below

{"parameters":[{"name":"network","value":{"value":"10.0.0.0/24", "objectType":"string" }, "type":"string" },{"name":"hostname","value":{ "value":"test-hostname.dom", "objectType":"string" }, "type":"string" }]}

FWIW this is the actual return from a workflow for a string parameter named "description":

{"name":"description","value":{"value":"Your text goes here","objectType":"string"},"type":"string","scope":"LOCAL"}

0 Kudos
asnodgrass
Contributor
Contributor
Jump to solution

Good insight on the structure of the value parameter, BillSkulley, thank you for that.  Sadly, the documentation completely omits this detail.  However, I tried amending my code accordingly and am still getting the same error back from Orchestrator.  I think I will follow this up with a ticket to my support representative.

Accept: application/json
Accept-Encoding: gzip, x-gzip, deflate, x-bzip2
Authorization: Basic **********
User-Agent: REST::Client/249
Content-Length: 128
Content-Type: application/json
{"parameters":[{"value":{"objectType":"string","value":"10.0.0.0/8"},"name":"network","type":"string"},{"value":{"objectType":"string","value":"test-hostname.dom"},"name":"hostname","type":"string"}]}

HTTP/1.1 400 Bad Request
Connection: close
Date: Mon, 10 Dec 2012 16:22:03 GMT
Server: vCO Server
Content-Length: 965
Content-Type: text/html;charset=utf-8
Client-Date: Mon, 10 Dec 2012 16:27:34 GMT
Client-Peer: x.x.x.x:8281
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=VMware/OU=VMware/CN=localhost.localdom
Client-SSL-Cert-Subject: /C=US/O=VMware/OU=VMware/CN=localhost.localdom
Client-SSL-Cipher: DHE-RSA-AES256-SHA
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Title: JBossWeb/2.0.1.GA - Error report
<html><head><title>JBossWeb/2.0.1.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The request sent by the client was syntactically incorrect ().</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.1.GA</h3></body></html>
0 Kudos
igaydajiev
VMware Employee
VMware Employee
Jump to solution

There was an issue with the deserialization of the value from JSON format, it is fixed and will be available in 5.1 U1 release.

0 Kudos
asnodgrass
Contributor
Contributor
Jump to solution

Thank you for the information! Looking forward to U1's release.

0 Kudos