Unable to write data to ThingSpeak , HTTP error 400

Hello,
I am trying to transfer data by using program "Typical Write Example" running on ESP8266 NodeMCU. I didn't change he program , only added my Network name, network password, channel number and APIWriteKey. The Program is running on ESP8266 or ESP32. In both cases the response is always "400".
Don't have more detailed information.
Any idea on the cause ? Router problem , Arduino IDE 1.8.10 or ?
Any comment is appreciated.
Kind regards

回答 (3 件)

Vinod
Vinod 2020 年 1 月 6 日

0 投票

Hello Otto,
Can you start from one of the examples in the library here: https://github.com/mathworks/thingspeak-arduino
Are you getting 400 status codes for those examples?
-Vinod

1 件のコメント

Otto Meier
Otto Meier 2020 年 1 月 6 日
Hello Vinod,
many thanks for your fast response.
I tried just the example "Typical Write Example" and it responses only 400 status code.
Otto

サインインしてコメントする。

Christopher Stapels
Christopher Stapels 2020 年 1 月 6 日

0 投票

Can you try to update your channel from a web browser? Use the format
Does that work?

9 件のコメント

Otto Meier
Otto Meier 2020 年 1 月 6 日
Hello Christopfer,
I tried several times, but there is no indication in the field1 chart.
Christopher Stapels
Christopher Stapels 2020 年 1 月 6 日
Was there a response in the browser when you entered the command?
Otto Meier
Otto Meier 2020 年 1 月 6 日
no, there was no response in the browser (Firefox)
Otto Meier
Otto Meier 2020 年 1 月 6 日
Sorry, I just recognized a "0" in the top left corner of the screen
Christopher Stapels
Christopher Stapels 2020 年 1 月 6 日
That might mean you have the incorrect API key. Can you check to be sure you are using the Write API key from the channel view and not your user API key, or could you have possibly made a typo?
Otto Meier
Otto Meier 2020 年 1 月 6 日
I checked the Write API key once more:
consisting of 16 digits: 12 capital letters and 4 figures.
Otto Meier
Otto Meier 2020 年 1 月 6 日
I just copied the the API Request from the "API Keys " -pages in the browser and got following responses:
first enter : 1
2nd enter: 2
3rd enter: 3
is this the response you are expecting?
But cannot see any difference to the previous commands
Otto Meier
Otto Meier 2020 年 1 月 6 日
I guess I could solve the problem:
Write API Key contains a "O" and I typed a "0" (Zero). Sorry , I did not recognize !!!
That was the difference why the copied command from the API request which worked.
Many thanks for your patience and best regards from Germany
Christopher Stapels
Christopher Stapels 2020 年 1 月 8 日
Glad you got it! Thanks for letting us know.

サインインしてコメントする。

Nazmi Rosly
Nazmi Rosly 2021 年 8 月 16 日
編集済み: Christopher Stapels 2021 年 8 月 17 日

0 投票

Hi. Im trying to send data from matlab which is the data from serial monitor from arduino. It is fine until 9th of data and then it stopped and says :
Error using Untitled (line 27)
'Values' must have a maximum of 9 elements, including the timestamp.
My coding is:
clear all
s = serial('com4');
fopen(s);
i = 1;
while(1)
data(i)= str2double(fscanf(s));
plot(data);
title('Temperature Monitoring')
xlabel('Time')
ylabel('Temperature')
pause(30);
i=i+1;
%thingSpeakWrite(1463959,data,'WriteKey','xxxxxxxxxxxxxxxx')
% Generate timestamps for the data
%tStamps = datetime('now')-minutes(9):minutes(1):datetime('now');
channelID = 1463959; % Change to your Channel ID
writeKey = 'xxxxxxxxxxxxxxxx'; % Change to your Write API Key
% Write 10 values to each field of your channel along with timestamps
tStamp = datetime('now')
thingSpeakWrite(1463959,data,'WriteKey','xxxxxxxxxxxxxxxx','TimeStamp',tStamp)
end

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

ヘルプ センター および File ExchangeRead Data from Channel についてさらに検索

製品

質問済み:

2020 年 1 月 6 日

編集済み:

2021 年 8 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by