How to include field value in ThingHTTP URL GET Request
Mostrar comentarios más antiguos
I am trying to include a field value in a ThingHTTP GET request but have not been successful.
For example, I have have successfully used
to send a specifice value to an external site, but was unsuccessful when I tried to send a ThingSpeak channel field value in a similar way. I used the %% method, which works for ThingTweet, but that didn't seem to work here. e.g.
Am I doing something wrong, or is there an alternative method for doing this?
3 comentarios
paul
el 14 de Mzo. de 2025
Movida: Walter Roberson
el 15 de Mzo. de 2025
Did you ever find a fix to this? Unless I'm missing something trying to save a thinghttp containing a url with placeholders in now results in a generic error...
"Please try again!
There were some problems creating your ThingHTTP:
Provide a valid URL for your ThingHTTP."
Warren Stanley
el 16 de Mzo. de 2025
Movida: Rena Berman
el 17 de Mzo. de 2025
paul
el 17 de Mzo. de 2025
Thank you @Warren Stanley That's exactly the pointer I needed, this approach certainly is the way forward!
Respuestas (1)
Sachin Lodhi
el 18 de Jul. de 2024
0 votos
Hi Warren,
It looks like you are on the right track, but there are some things that need to be considered when using ThingHTTP for GET requests with dynamic data from ThingSpeak channels. The %% notation is indeed used for placeholders, but the setup must be done correctly in ThingHTTP.
Here is a step-by-step guide to help you set this up:
- Click Apps > ThingHTTP, and then click New ThingHTTP.
- The next step is to configure the ThingHTTP. See the following section to properly configure ThingHTTP. https://www.mathworks.com/help/thingspeak/thinghttp-app.html#bvtzy2y-1:~:text=New%20ThingHTTP.-,Specify%20settings,-.%20Not%20all%20settings
- Finally, test the ThingHTTP url. Once saved, You can use POSTMAN to try out your HTTP requests using the RESTful API for ThingSpeak.
If the above steps are correctly followed, the placeholder `%%channel_1234567_field_1%%` should be replaced with the actual value from the specified ThingSpeak channel and field.
Please note that if this does not resolve your query, then following these troubleshooting steps can help -
- Check Channel ID and Field Number: Ensure that the channel ID and field number are correct.
- Public or Private Channels: Replacement requests to private channels not owned by the same user as the ThingHTTP request return blank values.
- URL Encoding: Make sure the URL is properly encoded if it contains special characters.
If you follow these steps and ensure all configurations are correct, you should be able to successfully include a ThingSpeak channel field value in your ThingHTTP GET request.
I hope this helps!
Categorías
Más información sobre Act on Data en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!