VMware Cloud Community
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

rest plugin json vs xml

how do you set the output type of the rest call to xml?

all my queries return json which is a little harder to process on the vco side. I recall it asking me the format somewhere but I can't find it now.

0 Kudos
1 Solution

Accepted Solutions
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

never mind i found this.

request.setHeader("Accept" ,"application/xml");

View solution in original post

0 Kudos
3 Replies
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

never mind i found this.

request.setHeader("Accept" ,"application/xml");

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Probably obvious, but it should be noted that setting 'Accept' header in the client request may not always work. For example, a REST service can be written in a way which produces only json (or some vendor-specific format) responses.

It seems that the trend is toward json, which is considered easier to parse/consume by languages other than Java/.NET

mcfadyenj
Hot Shot
Hot Shot
Jump to solution

in this case I am good to go as this is internally written.

I noticed some posts on the web pertaining to a JSON parser yet I cannot find any doco in the api guide pertaining to hacking up JSON responses.

Is this a native java function vs a vco api? In the meantime using xml and e4x worked well, e4x is so much easier than using xmldom. Coincidentally our dev said the same thing about the json responses being more prevalent.

0 Kudos