Integration of JSON data from HTTP/S API

Thanks. Now get things works with the format Bearer ACCESS_TOKEN.
I am trying to post a cmd:
https://platform.mydevices.com/v1.1/things/thingsId/cmd
it still returns an unauthorized message:
{
“statusCode”: 401,
“error”: “Unauthorized”,
“message”: “Missing authentication”
}

Ah, thanks for pointing this out to us! We’ll have to update this endpoint internally to allow POST commands, I’ll keep you updated.

I also noticed that the docs mentioned sending a JSON payload and it should be params. For example: https://platform.mydevices.com/v1.1/things/{thing id}/{cmd}

Ok. please let me know when I can get access to post cmd.

I didn’t get what you mean param instead of JSON. This is what used to post:

.


Did you mean the value and channel should be parameter? like:
https://platform.mydevices.com/v1.1/things/{thing id}/cmd?value=0&channel=2 ??
Why you add{} for cmd? Does it mean there are some other cmds? like /data /cmd /digital or something else?
Thanks

Hi, @rsiegel
Could you read the reply by hcortes and see if you can open the POST commands recently? Thank you very much!

Hi @xiaozhiyong1988

Just hang in there, we will be making an update to the platform API which will include this bugfix that you mentioned :smiley:

When the route is updated, the correct implementation will be https://platform.mydevices.com/v1.1/things/{thing id}/cmd

Where the {thing id} param will need to be replaced by the sensor id that you would like to update.

The payload that is sent through POST will require the following attributes:

{
   "channel": 0 (int channel value for sensor),
   "value": "String value, for example 1 (turns on an actuator)"
}

Hi @xiaozhiyong1988,

An API update has now been deployed, including the bug fix for the cmd issue you were having! :slight_smile:

Also made some minor changes on previous post for sending the command.

Doesn’t seem like I can save my edit at the moment. :stuck_out_tongue:

For this call you’ll want to use the following POST : https://platform.mydevices.com/v1.1/things/THING ID/cmd

And easy way to get your thing id for the MQTT device you want to send a command to is to view go to your device within your dashboard and you’ll see a url like this: http://cayenne.app/cayenne/dashboard/device/THING ID

For the payload, it will be the following:

{
"channel": "0" (string for channel, not int as previously mentioned)
"value": "1" (example)
}

And to POST, please use your access token as a header -H 'Authorization: Bearer ACCESS TOKEN

1 Like

Thanks. I will check it recently.

Hi, @hcortes
I tried use: https://platform.mydevices.com/v1.1/things/ID/cmd
and
{
“channel”: “2”,
“value”: “1”
}
to post. It returns:
{
“success”: true
}

but the channel 2 does not change to 1.

Hi @xiaozhiyong1988, @hcortes, did you guys ever sort this out or is this still an open issue?

Hi @xiaozhiyong1988,

Just to verify, is the device an mqtt device (BYOT)? Also if there is no widget with the specified channel in the payload then an auto populating widget will appear with the value you sent.

Also for these commands, it will work best for actuators (buttons and sliders) which are added as Custom Widgets

1 Like

How is this fix going?

I know we have a big docs update queued up between small things like this, and larger issues like the broken links and images we have. Thanks for your patience while we get it out the door, I don’t think it should be terribly longer here.

1 Like

can’t wait for it sir :smiley:

1 Like

@xiaozhiyong1988 (or anyone else) how did you manage to create users and add the redirect_uri? I can’t find any information on how to create the JWT authorization (which I think is required for those operations)

still waiting for this. because today i am also working on it but it’s not working. if you resolved this issue please kindly let me know.