system
(system)
January 22, 2022, 5:03am
1
@Stan P
I try send request using Posman. Tago share Postman Collection “TagoIO API” but I get No Authorization response:
{
“status”: false,
“message”: “Authorization denied”
}
How I can add Auth? I try do new key using this article: https://docs.tago.io/en/articles/218 and paste generated key as “Bearer Token” to my postman but I still have same respond as above.
PS. Of course I add device-token to header, this two parameters:
Content-Type: application/json
device-token: b4766ce8-7d31-cdbb-548d-xxxxxxxxxxxx
system
(system)
January 22, 2022, 5:03am
2
@Guilherme Costa
Hi @sosnus15
The second parameter actually is Authorization
Try like this:
Content-Type: application/json
Authorization: b4766ce8-7d31-cdbb-548d-xxxxxxxxxxxx
-Guilherme
system
(system)
January 22, 2022, 5:03am
3
@Stan P
Thanks for reply. Unfortunately I still have same problem. I export this from postman to cURL, but in console this still not working.
curl --location --request POST 'https://api.tago.io/data' \
--header 'Content-Type: application/json' \
--header 'Authorization: b4766ce8-7d31-cdbb-548d-c0bcXXXXXXXX' \
--data-raw '[
{
"variable": "pressure",
"value": "1019",
"location": {
"lat": "50.456706",
"lng": "20.6008"
},
"metadata": "<object>",
"serie": "ullamco",
"unit": "hPa",
"time": "2021-06-09T09:21:54.243Z"
},
{
"variable": "temperature",
"value": "21.1",
"location": {
"lat": "50.456706",
"lng": "20.6008"
},
"metadata": "<object>",
"serie": "commodo do irure consectetur",
"unit": "°C",
"time": "2021-06-09T09:21:54.243Z"
}
]'
system
(system)
January 22, 2022, 5:03am
4
@Guilherme Costa
Hi @sosnus15 ,
If you’re trying to do a POST request to a device, you’ll need to get the device token and place into authorization →
See how to get device-token →
copy and paste into the param Authorization
-Guilherme
system
(system)
January 22, 2022, 5:03am
5
@Stan P
Thank You, it working!
What I changed?
Generated header auth one more time
Removed " from lat and lng variables
remove field “metadata”
My new respond from tago is:
{
“status”: true,
“result”: “2 Data Added”
}
This is my fixed cURL command:
curl --location --request POST 'https://api.tago.io/data' \
--header 'Content-Type: application/json' \
--header 'Authorization: a3fd0e6a-3f82-480f-ba47-a567XXXXXXXX' \
--data-raw '[
{
"variable": "pressure",
"value": "1019",
"location": {
"lat": 50.4567,
"lng": 20.6008
},
"unit": "hPa",
"time": "2021-06-09T09:21:54.243Z"
},
{
"variable": "temperature",
"value": "21.1",
"location": {
"lat": 50.4567,
"lng": 20.6008
},
"unit": "°C",
"time": "2021-06-09T09:21:54.243Z"
}
]'