Permanent Redirect with URL v0

Kenneth_rf
Here to help

Permanent Redirect with URL v0

Hi,

 

This will be my first post in this community. I am making a script to update my device on the network.

I have some problems with SM, especially with Updates.

 

From what I see, Meraki API version 1 does not yet have all the options that v.0 for SM offers.

 

$ resp = Invoke-RestMethod "(....)api.meraki.com/api/v0/networks/${net}/sm/devices/tags"    -Method 'PUT' -Headers $ headers -Body $ body | ConvertTo-Json

 

When using this url I get the following error and I cannot find an alternative solution for version 1

 

Invoke-RestMethod : The remote server returned an error: (308) Permanent Redirect.

3 Replies 3
PhilipDAth
Kind of a big deal
Kind of a big deal

You are probably being redirected to the shard where the service is located.  Have you tried following the redirect?

 

Another option is to use the mega proxy instead which doesn't use redirects.

api-mp.meraki.com

John_on_API
Meraki Employee
Meraki Employee

You are correct that some v0 endpoints do not yet have v1 equivalents, and this is one of them.

 

https://developer.cisco.com/meraki/api/#!update-network-sm-devices-tags

 

Could you share more of your surrounding code? Please use the code-block formatting to preserve spacing and indentation.

Kenneth_rf
Here to help

function Put_Tag{

param(
[parameter(mandatory)][string]$serial,
[parameter(mandatory)][string]$tag,

[parameter(mandatory)][string]$value_net
)

 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "*/*")
$headers.Add("Content-Type", "application/json")
$headers.Add("X-Cisco-Meraki-API-Key", $global:API_Key)

 

$body = "{
`n `"serials`":`"${serial}`",
`n `"updateAction`": `"add`",
`n `"tags`": `"${tag}`"
`n}"


$url="https://api.meraki.com/api/v0/networks/$(value_net)/sm/devices/tags"

$response = Invoke-RestMethod $url -Method 'PUT' -Headers $headers -Body $body | ConvertTo-Json
return $response

}

Get notified when there are additional replies to this discussion.