HTTP Put not working with Thingsboard

I’m trying to do an HTTP Put to Thingsboard.com. I have it working with WiFi using urequests.

response = urequests.post(url, data=ujson.dumps(payload), headers=headers)

I’ve tried to use cellular by specifying the full URL in my conig.json as
“http”:{
“server”:“http://thingsboard.cloud/api/v1/*key removed*/telemetry”,
I’m using the following example PUT code but I keep getting:

INFO: {‘response’: [‘{“timestamp”:“2025-01-10T22:22:31.958+00:00”,“status”:405,“error”:“Method Not Allowed”,“path”:“/api/v1/Key Removed/telemetry”}’, ‘OK’, ‘+QHTTPREAD: 0’], ‘status’: 0}

Is there something I am missing?

import json
import time
from pico_lte.utils.status import Status
from pico_lte.core import PicoLTE
from pico_lte.common import debug
debug.set_level(0)
picoLTE = PicoLTE()

picoLTE.network.register_network()
picoLTE.http.set_context_id()
picoLTE.network.get_pdp_ready()
picoLTE.http.set_server_url()

debug.info(“Sending a PUT request.”)

payload_dict = {“Temp”: “22”,“Humidity”: “33”}
payload_json = json.dumps(payload_dict)
result = picoLTE.http.put(data=payload_json)
debug.info(result)

Read the response after 5 seconds.

time.sleep(5)
result = picoLTE.http.read_response()
if result[“status”] == Status.SUCCESS:
debug.info(“Put request succeeded.”)
debug.info(result)

Hi,

The 405 Method Not Allowed error indicates that the server you are trying to communicate with (in this case, ThingsBoard) is rejecting the HTTP method you are using (PUT ). ThingsBoard’s telemetry upload API typically expects a POST request rather than PUT .

Ensure that the endpoint you are using (/api/v1/Key/telemetry ) supports PUT requests.

Verify that your payload matches the expected format. For ThingsBoard telemetry, it should be a JSON object with key-value pairs.

If the issue persists even after changing to POST, consider: Testing the same request using tools like curl or Postman to verify server behavior.