Getting error 400 when adding a static route

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2017
11:44 AM
- last edited on
05-27-2022
04:00 PM
by
Paul Zimmerman
I have been experimenting with the API from PowerShell using cURL in insecure mode. I've been successful with my GET requests, but I am unable to successfully use a POST request to add a static route.
Here is the command I am using (with the private bits replaced):
curl -Lkvi -H "X-Cisco-Meraki-API-Key: $privatesBits" \
-H 'Content-Type: application/json' \
-X POST \
--data-binary \
'{"name":"testing","subnet":"192.168.4.13/32","gatewayIP":"192.168.248.9","enabled":"true"}' \
"https://$n000.meraki.com/api/v0/networks/$privateBits/staticRoutes"
I get an error 400: bad request back from the server:
< HTTP/1.1 400 Bad Request
As well as this feedback:
There was a problem in the JSON you submitted: not a number or other value at line 1, column 1 [parse.c:422]*
I have tested the same function in Postman with the same API key, URL, and json text with no problems. That is all well and good, but I would prefer to execute these tasks from a PowerShell script. What am I missing here? Is it necessary for me to provide a certificate for these changes to work? I get the same results using ConvertTo-Json in my script as well as when I hard code it. Passing it directly to cURL at the CLI gives the same results as well.
Any guidance would be greatly appreciated.
- Labels:
-
Meraki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 12:30 PM
Ive seen a problem that's maybe related, try escaping the double quotes. See if that helps.
reference:
https://stackoverflow.com/questions/55788754/cisco-aci-authentication-with-curl-doesnt-work
