It seems that the "request.setHeader("Accept","application/json")" is not working with HTTP-REST plugin 2.0.
I've configured an HTTP-REST host pointing to NSX and an Operation to get an Edge using the URL "/api/4.0/edges/{edgeId}". In the "Invoke Operation workflow" I add the following line:
request.setHeader("Accept","application/json")
This is working perfectly find on a vRealize Orchestrator 6.0.3 with HTTP-REST plugin version 1.0.9 and returns a JSON response. But with vRealize Orchestrator 7.0.0 using HTTP-REST plugin version 2.0.0 it returns a XML response.
How can I get the JSON response using version 2.0.0?
Thanks a lot!
D.
I found the answer myself.
Incredibly, with this version, this command doesn't work:
request.setHeader("Accept","application/json")
Instead, I need to use only lowercases:
request.setHeader("accept","application/json")
OMG!
I found the answer myself.
Incredibly, with this version, this command doesn't work:
request.setHeader("Accept","application/json")
Instead, I need to use only lowercases:
request.setHeader("accept","application/json")
OMG!
The problem seems to be that REST plug-in handles request headers in case-sensitive manner. The code responsible for request creation adds a default header 'accept=*/*', and if the user code adds a header like 'Accept=application/json', the request object will end up with 2 headers - accept and Accept. Later, when the code calls Apache httpclient, one of the values will overwrite the other (in your case, */* will overwrite application/json).
I opened a new PR to track this for next release.
The real problem is the backward compatibility. Now I need to change a lot of code.
D.
I know this is a bit dated and you have identified a work-around, but I want to close the loop on this issue: vRO 7.0.1 just released a couple days ago. From my tests, it appears that this issue has been resolved.
Thanks a lot, Burke, this is a very good news for me.
D.