http POST request returns 400 (bad request) #16376
Replies: 2 comments
-
Today I added to the "headers"
See also an image of the jsonPayload as a json file. however the error 400 kept coming. |
Beta Was this translation helpful? Give feedback.
-
In my honest opinion, this discussion possibly didn't get reponses earlier because it sounds to me like a "google sheets" question more than a microypthon question. You're getting response text from google that's saying your request is somehow malformed. What |
Beta Was this translation helpful? Give feedback.
-
The goal of my project is to send to a Google Sheets spreadsheet the following data:
a value from a MCP9808 temperature sensor;
a datetime string;
a board ID.
To achieve this the MPY script sends a https POST request to a Google Apps Script.
I already did these kind of things for other types of boards and other programming environments (Arduino and Circuitpython).
Hardware used:
a Pimoroni PicoPlus2 (RP2350) microcontroller;
a Pimroni RM2 (WiFi/BLE) module;
an Adafruit MCP9808 temperature sensor.
The PicoPlus2 is flashed with Micropython (MicroPython feature/psram-and-wifi, pico_plus2_rp2350 v0.0.10 on 2024-11-18; Pimoroni Pico Plus 2 (PSRAM + LTE + WiFi) with RP2350).
The data the PicoPlus2 sends is accepted and handled by the Google Apps Script.
The data is arriving in the spreadsheet.
A Logger info writes to a Logger spreadsheet. The result is: "success", however the response to the post request, that the MPY script receives is: 400 (bad request).
I googled for similar cases but did not found any. I created a discussion post in the discussion page of Micropython.org on Github however no reply sofar.
The Google Apps script has been deployed and set for access to anyone. The apikey is limited for websites; with restrictions to spreadsheet where the data has to go; the Logger spreadsheet; https://script.google.com/home/projects/; https://script.google.com/macros/; https://www.googleapis.com/auth/spreadsheets/*
Question: anyone who can tell me what could cause the 400 response?
Below I will copy the most important lines related to the POST. I uploaded images of the spreadsheet and its content and of the hardware used: images.
Extract of the script, function
handle_request()
:I think the request is not
illegal
because it is accepted and handled by Google Apps.Question: anyone who can explain me where the request could be malformed?
Beta Was this translation helpful? Give feedback.
All reactions