iOS Shortcuts Rest API (PUT)

SOLVED
RubenG
Getting noticed

iOS Shortcuts Rest API (PUT)

Hello,

 

Currently trying to utilize the Rest API using Shortcuts on iOS.

 

I need some help trying to use the PUT command through shortcuts on iOS. I have tested the same setup with a get command and it works without issues. I can't figure out a way to change the ssid name. Basically updating any parameter through PUT. Not sure if its an issue on the way I am using the Headers or the Body to pass through all the variables that need to be updated. 

 

image1.png

1 ACCEPTED SOLUTION
BrechtSchamp
Kind of a big deal

Hmm, that'll be a hard one to crack. What baseURL are you using?

 

If you're using:

https://api.meraki.com/api/v0

Try replacing it with the actual shard your organization is on:

https://n123.meraki.com/api/v0/

View solution in original post

7 REPLIES 7
BrechtSchamp
Kind of a big deal

Couple of things:

  • The numbering starts at 0 and goes up to 14, couldn't see in your screenshot what number you were using.
  • You might want to test your values in Postman first, in case there is an issue with the access rights of the account you're using.
  • I think application/json is supposed to be using a forward slash, not sure if that matters.
  • Body looks to be correct, I've tested with Postman and I was able to change an SSID to hi with that body.
  • Is there any error that is returned?

Yes, I tested in Postman it worked no issue and used the Code option to view it in python Code to get more visibility. 

I am using the option "1" for the SSID to indicate the Second SSID.

I have tried with a "/", I was just testing all the options at this point.

 

I think the issue is on the way it handles the Body and additional Header for Content Type.

I tried it without the content Type and still did not work.

 

unfortunately it doesn't give me any sort of error. Unless you know of a way to add a function to the shortcuts to show the error. It just stalls on that part of the sequence. Like such:

IMG_5153.PNG

BrechtSchamp
Kind of a big deal

Hmm, that'll be a hard one to crack. What baseURL are you using?

 

If you're using:

https://api.meraki.com/api/v0

Try replacing it with the actual shard your organization is on:

https://n123.meraki.com/api/v0/

Awesome, it worked. Did not think to do that.

 

The GET command worked with:

https://api.meraki.com/api/v0
https://dashboard.meraki.com/api/v0

So I assumed it would work with the PUT. Thanks for that the shard for my organization was my solution. Don't know why. If you have more information as to why please let me know. It would be awesome to know.

 

The PUT command works on postman without the org shard.

 

Now off to program Siri to turn on and off my wifi. 

BrechtSchamp
Kind of a big deal

Good to hear!

 

The reason why is described here:

Note also that most HTTP libraries and clients will not follow a redirect with an HTTP verb other than GET, and may instead follow the redirect but substitute GET for the HTTP verb. As a result, you may find a redirect on DELETE, POST, or PUT will look as though a GET was requested. To avoid this, first perform a GET on the organization you are working with, and store the URL you are working with, then use that URL for subsequent requests (particularly those that modify state).

 

Source:

https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API...

 

 

Thanks Brecht!

Also want to point this out. Seems that on the iOS Shortcuts it wasn't following the redirect. According to the documentation it is up to the client to follow the redirect.

 

Organizations

Retrieve the list of organizations for the API key specified in X-Cisco-Meraki-API-Key:

GET https://api.meraki.com/api/v0/organizations
Response code: 302Response: redirect to https://n123.meraki.com/api/v0/organizations

Note that the request is redirected to n123.meraki.com. A 302 may happen on any API call, including those that modify state such as DELETE, POST, and PUT. When a GET is redirected, the status code will be 302. When a non-GET is redirected, the status code will be 307 for Postman, or 308 for any other client. Client applications must follow these redirects. No action will be taken by the host issuing the redirect, so even non-idempotent requests are safe to retry on the new host.

BrechtSchamp
Kind of a big deal

Indeed it is :).

Get notified when there are additional replies to this discussion.