Http Get / Repsonse issue

I’m trying to do an HTTP get of the current time as a way of keeping the system clock updated. My code is pretty much right out of the example. I can see the json results displayed in the debug but I cannot retrieve the datetime. See debug code below the code.

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 GET request.")

result = picoLTE.http.get()
debug.info(result)

# Read the response after 5 seconds.
time.sleep(5)
result = picoLTE.http.read_response()

debug.info(result)
if result["status"] == Status.SUCCESS:
    debug.info("Get request succeeded.")


DEBUG Below

DEBUG: Processed: ['+CGACT: 1,1', '+CGACT: 2,0', 'OK']
DEBUG: Desired: +CGACT: 1,1
DEBUG: check_pdp_context_status  : {'response': ['+CGACT: 1,1', '+CGACT: 2,0', 'OK'], 'status': 0}
DEBUG: success                   : {'response': ['+CGACT: 1,1', '+CGACT: 2,0', 'OK'], 'status': 0}
DEBUG: Processed: ['CONNECT']
DEBUG: Response: ['\r\nOK\r\n']
DEBUG: Processed: ['OK']
INFO: Sending a GET request.
DEBUG: Response: ['\r\nOK\r\n']
DEBUG: Processed: ['OK']
DEBUG: Response: ['\r\nOK\r\n']
DEBUG: Processed: ['OK']
INFO: {'response': ['OK'], 'status': 0}
DEBUG: Processed: ['+QHTTPGET: 0,200,349', 'CONNECT', '{"utc_offset":"-05:00","timezone":"America/New_York","day_of_week":3,"day_of_year":1,"datetime":"2025-01-01T18:28:56.367500-05:00","utc_datetime":"2025-01-01T23:28:56.367500+00:00","unixtime":1735774136,"raw_offset":-18000,"week_number":1,"dst":false,"a']
{'response': 'timeout', 'status': 2}
INFO: {'response': 'timeout', 'status': 2}
time= {'response': 'timeout', 'status': 2}

Hi,

The debug log shows that the datetime is included in the JSON response:

"datetime":"2025-01-01T18:28:56.367500-05:00"

Ensure that you are properly parsing the JSON response in your code. You can use the json library to extract the datetime field.

The debug log indicates a 'timeout' status when reading the response. Try increasing the time.sleep duration before calling http.read_response() .

That helps with the response which I was not aware was an issue but the main issue is that the data is not being sent to Thingsboard or is not in the correct format. That’s what I’m trying to work out.

This time I’m using your exact example for Put to Webhooks from the documentation. Nothing comes through to Webhooks and I get the following very similar error message. The documentation is terrible. Is there some real world example? Have you sold any of these boards? Is anyone using them?

DEBUG: Power status: 0
DEBUG: Power status: 0
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: COM: {‘response’: [‘OK’], ‘status’: 0}
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Response: [‘\r\n+CREG: 0,5\r\n\r\nOK\r\n’]
DEBUG: Processed: [‘+CREG: 0,5’, ‘OK’]
DEBUG: Desired: +CREG: 0,5
DEBUG: check_network_registration : {‘response’: [‘+CREG: 0,5’, ‘OK’], ‘status’: 0}
DEBUG: success : {‘response’: [‘+CREG: 0,5’, ‘OK’], ‘status’: 0}
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Response: [‘\r\n+CGACT: 1,1\r\n+CGACT: 2,0\r\n\r\nOK\r\n’]
DEBUG: Processed: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’]
DEBUG: Desired: +CGACT: 1,1
DEBUG: check_pdp_context_status : {‘response’: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’], ‘status’: 0}
DEBUG: success : {‘response’: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’], ‘status’: 0}
DEBUG: Processed: [‘CONNECT’]
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
INFO: Sending a PUT request.
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Processed: [‘CONNECT’]
DEBUG: Processed: [‘OK’]
DEBUG: Processed: [‘OK’, ‘+QHTTPPUT: 0,400,90’]
INFO: {‘response’: [‘OK’, ‘+QHTTPPUT: 0,400,90’], ‘status’: 1}
DEBUG: Processed: [‘CONNECT’, ‘

400 Bad request

\nYour browser sent an invalid request.\n\n’, ‘OK’, ‘+QHTTPREAD: 0’]
INFO: Put request succeeded.
INFO: {‘response’: [‘

400 Bad request

\nYour browser sent an invalid request.\n\n’, ‘OK’, ‘+QHTTPREAD: 0’], ‘status’: 0}