Hello,
I'm trying to follow instructions for Postman to bulk update device names based on their serial number. I keep getting a 502 Bad Gateway error. I'm able to run different commands for getting my Organization and Network IDs so I know what I'm doing is partially working, I just can't get to the finish line. I'm hoping someone here can help. I have an open ticket with Meraki but it has gone quiet.
My most recent attempts have been using a fork of the public Meraki Dashboard API - v1.10. This is the PUT command:
{{baseUrl}}/networks/:networkId/sm/devices/fields?serial={{serial}}&deviceFields={"name":{{name}}"}
My networkID is set as a variable as well as my X-Cisco-Meraki-API-Key Header.
Here is the Code Snippet from Postman if that's helpful, with my network ID and API Key X'd out.
import requests
import json
url = "https://api.meraki.com/api/v1/networks/N_5XXXXXXXXXXXXX5/sm/devices/fields?serial=&deviceFields={\"name\":{{name}}\"}"
payload = json.dumps({
"deviceFields": {
"name": "<string>",
"notes": "<string>"
},
"wifiMac": "<string>",
"id": "<string>",
"serial": "<string>"
})
headers = {
'X-Cisco-Meraki-API-Key': 'fXXXXXXXXXXXXXXXXXXXXXXXXX3',
'Content-Type': 'application/json'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
When I run the collection I'm using a CSV file with a serial column and name column. A single entry for testing. This is what the data preview looks like:
Thanks for any suggestions,
Ross
Solved! Go to solution.
I got the following to work using "Modify the fields of a device"
Leave the Params unchanged. Enter your networkid in the Path Variables
{{baseUrl}}/networks/:networkId/sm/devices/fields
Go to the Body and modify it, adding bracketed entries to match the headers in your CSV file.
{
"deviceFields": {
"name": "{{name}}"
},
"serial": "{{serial}}"
}
This video provided me with the idea. https://www.youtube.com/watch?v=wjPmW-EIpTw&t=202s
I am trying to do this same thing but I'm a Postman noob. I found this article for the older API version.
Thanks. That's where I started out but was getting the same error so I started expanding my search and found the newer API version but with the same results unfortunately.
Are you getting the same error? 502 Bad Gateway?
I'm attempting to edit the existing "Modify the fields of a device" under PRODUCTS > sm > Configure > Fields.
I'm not bothering with the CSV file part yet, I'm just trying to get it to work by filling in the fields for one device.
{{baseUrl}}/networks/:networkId/sm/devices/fields?serial=&name=
After filling in the fields it will look like this, pulling the networkId from a path variable.
{{baseUrl}}/networks/:networkId/sm/devices/fields?serial=xxxxxxxxxx&name=RenameTest
The error I get is 400 bad syntax.
Reply body is:
{"errors":["Invalid parameters(s): name"]}
I got the following to work using "Modify the fields of a device"
Leave the Params unchanged. Enter your networkid in the Path Variables
{{baseUrl}}/networks/:networkId/sm/devices/fields
Go to the Body and modify it, adding bracketed entries to match the headers in your CSV file.
{
"deviceFields": {
"name": "{{name}}"
},
"serial": "{{serial}}"
}
This video provided me with the idea. https://www.youtube.com/watch?v=wjPmW-EIpTw&t=202s
Thank you! This worked. I did have to set the Body to Raw - JSON for it to work though. It went in as Raw - Text at first which did not work. I noticed it was JSON in the video you posted so I tried that and it worked!