This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AT Commands for JSON POST (Serial LTE Modem) Example

I'm running the Serial LTE Modem firmware and utilizing the reference docs in the LTE Link Monitor Terminal (My commands in yellow, blue/grey text is response)

NCS 1.4, SLM firmware, https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/HTTPC_AT_commands.html

AT+CFUN=1

OK

AT+CFUN?

<bunch good things showing its connecting>

AT#XHTTPCCON=1,"test.domain.com",5000

#XHTTPCCON:1

OK

AT#XHTTPCREQ="POST","/post2","Host: test.domain.com:5000\nAccept: */*\nContent-Type: application/jsonl charset=utf-8\nContent-Length: 34",34

OK

#XHTTPCREQ:1

#XHTTPCREQ:1

OK

\n{"key1":"value1", "keyZ":"valueZ"}

OK

AT#XHTTPCCON=0

#XHTTPCCON=0

OK

Ready

Now my server does not see the JSON payload, I've tried multiple things on #XHTTPCREQ:1, but my server is just seeing this as an attempt at a form submission without a proper data payload (at least my little python-based Flask echo server does).  This makes no sense to me as I specifically sent the content-type to be application/json.

Im trying to evaluate these boards as a drop-in replacement option for Digi LTE modems (We're consistently getting 28-300+ second connect time with Digi, and 3-6 second connect time with the NRF9160 chips) on a custom MCU board we're using, so the preference is to get an AT Command protocol in place as those MCUs already interface over AT commands.

I just want to get a "hello, world" equivalent working with JSON payload over HTTP before I start looking at HTTPS/MQTT options going forward.  Any help here would be greatly appreciated.

~Evan

Parents
  • Hi!

    Sorry about the slow response time.

    I just wanted to let you know I'm working on your case. I have not been able to reproduce this issue yet, but I'll let you know if I have any updates. 

    Content-Type: application/jsonl charset

    I'm pretty sure there's supposed to be a semi-colon after json, and before charset?

    Best regards,

    Heidi

  • Thanks Heidi.

    I did not copy/paste this in correctly here but had tried so many combinations that I’m certain that’s not the core issue.  I’ll reattempt later today just incase to be sure, however.

    ~Evan

  • Hi, I haven't been able to reproduce this issue, unfortunately. 

    Please add CONFIG_AT_CMD_LOG_LEVEL_DBG=y to the prj.conf file and then provide me the resulting log file from running the application.

    Also, if you're able to take a modem trace, that would be very helpful. 

    Best regards,

    Heidi

  • Can you please give me your list of AT commands in the LTE Link Monitor that successfully performs an HTTP POST with a JSON payload using the default Serial LTE Modem firmware?  This isn't a firmware issue, it's a documentation one.

    The documentation states a JSON payload can be sent, but the example (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/HTTPC_AT_commands.html) is for application/x-www-form-urlencoded data:

    AT#XHTTPCREQ="POST","/post","User-Agent: SLM/1.2.0
    Accept: */*
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 20
    ",20
    OK
    #XHTTPCREQ: 1
    12345678901234567890
    OK
    #XHTTPCREQ: 0
    #XHTTPCRSP: 576,1
    HTTP/1.1 200 OK
    Date: Wed, 09 Sep 2020 08:21:03 GMT
    Content-Type: application/json; charset=utf-8
    Content-Length: 405
    Connection: keep-alive
    ETag: W/"195-JTHehAiV7LQRCKihfzcZBX1rgGM"
    Vary: Accept-Encoding
    set-cookie: sails.sid=s%3AtApCs6p2Ja2on5dYO8QvhQSEEfnvkjOX.31HKOpZcip6MzzUoqPw2WZib0rPpimc5y10Mjczukoc; Path=/; HttpOnly
    {"args":{},"data":"","files":{},"form":{"12345678901234567890":""},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5f589067-d61d0850c65f3568f9c9e050","content-length":"20",#XHTTPCRSP:165,0
    "user-agent":"SLM/1.2.0","accept":"*/*","content-type":"application/x-www-form-urlencoded"},"json":{"12345678901234567890":""},"url":"">https://postman-echo.com/post"}

    ~Evan
Reply
  • Can you please give me your list of AT commands in the LTE Link Monitor that successfully performs an HTTP POST with a JSON payload using the default Serial LTE Modem firmware?  This isn't a firmware issue, it's a documentation one.

    The documentation states a JSON payload can be sent, but the example (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/HTTPC_AT_commands.html) is for application/x-www-form-urlencoded data:

    AT#XHTTPCREQ="POST","/post","User-Agent: SLM/1.2.0
    Accept: */*
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 20
    ",20
    OK
    #XHTTPCREQ: 1
    12345678901234567890
    OK
    #XHTTPCREQ: 0
    #XHTTPCRSP: 576,1
    HTTP/1.1 200 OK
    Date: Wed, 09 Sep 2020 08:21:03 GMT
    Content-Type: application/json; charset=utf-8
    Content-Length: 405
    Connection: keep-alive
    ETag: W/"195-JTHehAiV7LQRCKihfzcZBX1rgGM"
    Vary: Accept-Encoding
    set-cookie: sails.sid=s%3AtApCs6p2Ja2on5dYO8QvhQSEEfnvkjOX.31HKOpZcip6MzzUoqPw2WZib0rPpimc5y10Mjczukoc; Path=/; HttpOnly
    {"args":{},"data":"","files":{},"form":{"12345678901234567890":""},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5f589067-d61d0850c65f3568f9c9e050","content-length":"20",#XHTTPCRSP:165,0
    "user-agent":"SLM/1.2.0","accept":"*/*","content-type":"application/x-www-form-urlencoded"},"json":{"12345678901234567890":""},"url":"">https://postman-echo.com/post"}

    ~Evan
Children
Related