Script HTTP.POST to Shelly Cloud fails

  • Hello,

    I always get following error when trying to send HTTP.POST request:

    Zitat

    Return: {"body":"{\"isok\":false,\"errors\":{\"invalid_header\":\"Unauthorized! Wrong authorization header provided!\",\"invalid_token\":\"The login information is invalid! Please login again!\"}}"

    The curl command that works is:

    Code
    curl -X POST https://shelly-xx-eu.shelly.cloud/scene/enable?id=xxx -d "enabled=false&auth_key=xxx"

    I tried several formats, my recent try is:

    what's wrong?

    Many thanks for help!

  • It needs to be URL-encoded, I guess. At least, I couldn't get it to work with JSON. So, modify your request body to ensure your queries are URL-encoded, and update your header content type to "application/x-www-form-urlencoded" as well. Then, it should work.

    If it's not on a Shelly device, you could use OAuth to gain access to your Shelly cloud devices.


    SebMai
    5. Juni 2022 um 20:15