I am trying to use "Bulk-Write JSON Data" API to send some data to my ThingSpeak channel: https://www.mathworks.com/help/thingspeak/bulkwritejsondata.html
My channel has four fields: "Temperature", "Pressure", "Humidity", "CO2"
My POST query looks like this:
POST /channels/XXXXXX/bulk_update.json HTTP/1.1
Host: api.thingspeak.com
Content-Type: application/json
{
"write_api_key": "XXXXXXXXXXXXXXXX",
"updates":
[{
"created_at": "2018-06-21 22:21:40 +0300",
"Temperature": "27.51",
"Pressure": "746.02576",
"Humidity": "42.407",
"CO2": "978"
}
]
}
But server returns response:
{
"status": "400",
"error": {
"error_code": "error_bad_request",
"message": "Bad Request",
"details": "The request cannot be fulfilled due to bad syntax."
}
}
What is wrong?

 채택된 답변

Kojiro Saito
Kojiro Saito 2018년 6월 22일

1 개 추천

As key-value pairs of update says, key names should be created_at, delta_t, field<X>, latitude, longitude, elevation, status.
So, how about changing the field names of "Temperature", "Pressure", "Humidity", "CO2" to "field1", "field2", "field3", "field4", respectively?
{
"write_api_key": "XXXXXXXXXXXXXXXX",
"updates":
[{
"created_at": "2018-06-21 22:21:40 +0300",
"field1": "27.51",
"field2": "746.02576",
"field3": "42.407",
"field4": "978"
}
]
}

추가 답변 (1개)

Sergey Trofimov
Sergey Trofimov 2018년 6월 22일

0 개 추천

Yes, it helped. Thanks )

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

도움말 센터File Exchange에서 Read Data from Channel에 대해 자세히 알아보기

제품

질문:

2018년 6월 21일

답변:

2018년 6월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by