Is it possible to change a variable using an API or webhook from another system?

Dear forum

I know that you can use an Arduino Cloud IoT Webhook OUTGOING, from Arduino to an external system like IFTTT.

But I need an INCOMING API or webhook from another system to change a variable inside my Arduino Cloud system. I searched for a long time but found no examples. I've seen the API page (Arduino IoT Cloud API) which is HUGE, maybe the secret is there?

I expect something like the following URL to set one of my variable to e.g. 17:
https://api_xyz.arduino.cc/DeviceID/SecretKey/maybeAPIkey/Variable_name?value=17

Is this possible? Can somebody point me to a good starting point to learn more?

Thank you so much :slight_smile:

  • MakerAndy

P.S. No IFTTT or similar, I can only set up webhooks like above on another system and need to change variables on my Arduino Cloud.

you'll have to read it because it's the solution... You need to use one of the package they mention

Provides a set of endpoints to manage Arduino IoT Cloud Devices, Things, Properties and Timeseries. This API can be called just with any HTTP Client, or using one of these clients:

1 Like

Thank you J-M-L

After spending a long time trying to get it to work, I am able to change a variable with a ~50 line Python script (the following topic helped a lot: Setting and reading Thing variables via the Python API)

BUT I still did not manage to simply change a variable with 1 or 2 cURL (as I cannot run any code in my external system, just a webhook/cURL), shouldn't that be possible?

1. Get the Auth-Token

The following worked to get the Auto-Token (but I needed to change single to double quotes):

curl --request POST \
  --url 'https://api2.arduino.cc/iot/v1/clients/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'grant_type=client_credentials' \
  --data 'client_id=YOUR_CLIENT_ID' \
  --data 'client_secret=YOUR_SECRET_ID' \
  --data 'audience=https://api2.arduino.cc/iot'

2. Pass received Auto-Token to a second cURL to change the variable

I did not get this to work :frowning:
Shouldn't this be possible with a cURL, something like:

curl --request PUT 'https://api2.arduino.cc/iot/v2/things/YOUR_THING_ID/properties/YOUR_PROPERTY_ID/publish' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
-d '{"value":17}'

I get the following error message (and I tried all variants of quotes in the last line):

{"id":"xxx","code":"bad_request","status":400,"detail":"failed to decode request body with content type \"application/json\": invalid character 'v' looking for beginning of object key string"}

The background page (Arduino IoT Cloud API) is extremely long, but does not contain a single example. Are there some examples somewhere? Or I might post this in the "Jobs/Projects" section?

Thank you very much for your kind support!
MakerAndy

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.