dmalhot1
Contributor
Contributor

NSX-v 6.4 API error when Body is JSON but works if it is XML

Needed to automate some NSX stuff but I am stuck... I won't cry about JSON examples not being available in documentation .. Here is my issue :

I am using Golang however even Postman fails when using JSON as body payload

Method:POST

URI : https://nsx-mgr.local/api/2.0/vdn/scopes/vdnscope-1/virtualwires

Body ( JSON)

{

"virtualWireCreateSpec": {

"name": "Test-Logical-Switch",

"description": "Test",

"tenantId": "virtual wire tenant",

"controlPlaneMode": "HYBRID_MODE",

"guestVlanAllowed": "false"

}

}

Fails with error

{

"errorCode": 401,

"details": "Invalid Parameter.",

"rootCauseString": null,

"moduleName": null,

"errorData": null

}

But works when I use it with XML

Method:POST

URI : https://nsx-mgr.local/api/2.0/vdn/scopes/vdnscope-1/virtualwires

Body ( XML)

<virtualWireCreateSpec>

<name>Test-Logical-Switch</name>

<description>Test</description>

<tenantId>virtual wire tenant</tenantId>

<controlPlaneMode>HYBRID_MODE</controlPlaneMode>

<guestVlanAllowed>false</guestVlanAllowed>

</virtualWireCreateSpec>

I can convert the Body to XML when calling the API but this is bizarre . As per documentation Json is supported . Maybe I am missing something very simple ?

Tags (3)
0 Kudos
1 Reply
Czernobog
Expert
Expert

Did you explicitly state in the header, that the content type will be json in your api call? As in content-type = application/json. Per default I think the API expects text/xml.

0 Kudos