Insert data in data bucket from HTTP Get

Hello, I wanted to know if it is possible to insert data into a bucket from an http get. For example something similar to:
https://api.thinger.io/v1/users/{USER_ID}/buckets/{BUCKET_ID}/insertdata?temp=24?authorization={DEVICE_TOKEN}
Regards!

Hello @EED,
yes it is possible, you only have to create the bucket and an access token. There is some similar integration in our sigfox documentation, so you can learn how to do this here:
http://docs.thinger.io/sigfox/#steps-in-thingerio-create-an-access-token

best!

Hi @JorgeTrincado could you give us and example? I understand theory, but when I try to apply in Node Red, I have allways the same error: “cannot write to the requested bucket, check that is available and enabled”, and I sure that I fail because I don´t write Json properly
Thanks in advance!

Hi guys! actually @EED almost got it right.

you just have to create the Bucket and an Access Token with writing permissions to that bucket, then ussing a POST message, it is possible to call to:
https://api.thinger.io/v1/users/{USER_ID}/buckets/{BUCKET_ID}/data?authorization={ACCESS_TOKEN}

and send the data using an Application Json format. You can check it using postman or creating an endpoint profile with these specifications and execute it using the “test endpoint” feature of thinger.io web console:

then just write a simple json in the “Endpoint Call Payload” text box and click the test endpoint button to see the answer. If everithing is right you should see the information stored in your data bucket.

hope it helps!

I’m trying to do the same thing as the original poster, but I’ve been unsuccessful in building the correct url. I can build the url to view data in the bucket, but adding a json onto the end eludes me.
I’ve tried many iterations including:
https://api.thinger.io/v1/users/{USER_ID}/buckets/{BUCKET_ID}/data?authorization={ACCESS_TOKEN}&temp00=99.99

https://api.thinger.io/v1/users/{USER_ID}/buckets/{BUCKET_ID}/data?authorization={ACCESS_TOKEN}&data={“out”:{“temp00” : 99.99}}

Any help. The API reference online is lacking

Hello @Terry_Myers,

The problem is that the “data” and the JSON have to be included into the body of the message, it can’t be sent in the post and the message should include also an “application/json” header.

try using postman as explained in this part of the documentation: https://docs.thinger.io/devices/http-devices#building-the-http-request-in-the-data-source

If you are building the API from code, try with this example using WiFiClientSecure.h and ArduinoJson.h

   WiFiClientSecure.h and  ArduinoJson.h 

  //CREATTING JSON FOR THINGER.IO API
  StaticJsonDocument<200> doc;
  JsonObject root = doc.to<JsonObject>();

  root["example_key1"] = "helloWorld";
  root["example_number"] = 99;
  
  //serialice the json
  char JSONmessageBuffer[200];
  size_t size = serializeJson(root, JSONmessageBuffer);

  //create the message body
  String body((const char*)JSONmessageBuffer);

  //create the REST API 
  Link = "v1/users/<USER_ID>/buckets/<BUCKET_ID>/data?authorization="+String(ACCESS_TOKEN);

  httpsClient.print(
    String("POST ") + Link + " HTTP/1.1\r\n" +
    "Host: " + String(HOST) + "\r\n" +
    "Content-Type: application/json" + "\r\n" +
    "Content-Length: " + String(size) + "\r\n" +
    "Connection: close\r\n\r\n" + body);