VMware Communities
jagno
Contributor
Contributor

Validation error in APIv2 PATCH requests

I've started to play around with the VMware SD-WAN (née Velocloud) API. I've had a lot of success with gathering information using basic GET requests but I've been struggling to understand using it for configuration. For example, say I want to change the management traffic override setting. According to the docs I need to send a PATCH request with a 'PatchSchema' array:

VMware's example:

{
    "PatchSchema": [
        {
            "op": "replace",
            "path": "/softwareUpdate/windowed",
            "value": true
        }
    ]
}

This particular setting needs a DeviceSettingsLANManagementTraffic object, with both fields described as optional:

{
	"override": false,
	"sourceInterface": "string"
}

I'm using Python's Requests library, but here is VMware's example using cURL:

curl -X PATCH -H "Content-Type: application/json" -d '{"PatchSchema":[{"op":"replace","path":"/softwareUpdate/windowed","value":true},{"op":"remove","path":"/lan/networks/0"},{"op":"add","path":"/snmp/snmpv2c/allowedIp","value":"1.2.3.4"},{"from":"/lan/networks/0/interfaces/0","op":"remove","path":"/lan/networks/1/interfaces/1"}]}' https://{api_host}/api/sdwan/v2/enterprises/{enterpriseLogicalId}/edges/{edgeLogicalId}/deviceSettings

My basic request is:

body = json.dumps({"PatchSchema": {"op":"replace","path":"/lan/managementTraffic","value":{"override": True}}})
reqs = requests.patch(full_url, headers=head, data=body)

I can confirm that the url and headers are correct since I can perform GETs to the same endpoint without issue, but the PATCH requests keep returning the same error to me:

'{"code":"ValidationError","message":"Validation Error","errors":[{"message":"\\"value\\" must be an array","path":""}]}'

VMware's own docs show that as a JSON object, with the particular value as a boolean. I've also tried the following for the body but they're all either invalid or return the same result:

body = json.dumps({"PatchSchema": [{"op":"replace","path":"/lan/managementTraffic","value":{"override": True}}]})
body = json.dumps({"PatchSchema": {"op":"replace","path":"/lan/managementTraffic","value":[{"override": True}]}})
body = json.dumps({"PatchSchema": {"op":"replace","path":"/lan/managementTraffic","value":{"managementTraffic": {"override": True}}}})
body = json.dumps({"PatchSchema": {"op":"replace","path":"/lan","value":{"managementTraffic": {"override": True}}}})
body = json.dumps({"PatchSchema": {"op":"replace","path":"/lan","value":{"lan": {"managementTraffic": {"override": True}}}}})
body = json.dumps({"PatchSchema": {"op":"replace","path":"/lan/managementTraffic/override","value": True}})
body = json.dumps({"PatchSchema": [{"op":"replace","path":"/lan/managementTraffic/override","value": True}]})

I've tried to change other settings and apparently I just don't understand their documentation because I get the same error no matter what I've tried. Any ideas what I'm getting wrong?

Reply
0 Kudos
1 Reply
khirom
Enthusiast
Enthusiast

I tried to change the APIv2 settings using postman.
I changed the DHCP setting on the Edge from enabled to disabled and the configuration was successful.
The cURL at that time is below.

 

curl --location --request PATCH 'https://<vco>/api/sdwan/v2/enterprises/<enterprise-id>/edges/<edge-id>' \
--header 'Authorization: Token <token> \
--header 'Content-Type: application/json' \
--data-raw '[
    {
        "op": "replace",
        "path": "/lan/networks/3/dhcp/enabled",
        "value": "false"
    }
]'

Reply
0 Kudos