This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Format for HTTP request using AT commands in SLM application

Hi,

I am  trying to retrieve data from server using HTTP GET request, using AT command for Serial LTE modem application.

So, I can connect to the server using AT#XHTTPCCON command, but not able to get the data from the server. Here is the format for HTTP request I am sending to the nRF91600 over UART using nRF Connect v 3.7.0.

AT#XHTTPCREQ="GET","/instruments/150771004/temperature-values/?page=1 HTTP/1.1","Host: demo.abc.com\r\nAccept: application/vnd.api+json\r\nAuthorization: Basic ZGVtbzpkZxxx\r\n"

I put abc.com and xxx here in the Host and Authorization fields just because of company policy. 

The server is responding with 400 bad request error.

Can you please let me know if I am missing something in the header field format?

I have checked on the server side, and I can see upto the resource field (up to HTTP/1.1), its in correct format. So, I am guessing there is something to do with header field of the command.

I couldn't find any example from Nordic what should be the format if there is any header field in the HTTP request, i.e., for authorization etc.

I tried to get the SLM application in debug mode and I could see its getting the proper string for httpc.headers variable in handle_AT_HTTPC_REQUEST function of the slm_at_httpc.c source file.

I am using nRF Connect v 3.7.0, nRF Connect SDK v1.4.1, in software tools and nRF9160DK for the hardware.

Looking forward for a prompt response.

Regards,

Shivek

  • Hi Markus,

    Could you remove the "HTTP/1.1" part and check if that makes any difference?

    I already have tried removing HTTP/1.1. That also didn't work.

    I would strongly recommend update to at least NCS v1.5.0

    I tried with NCS v1.6.1, its the same 400 Bad request error I am getting.

    Would you be able to send me some example having more than one header fields as in my case, i.e., authentication, host etc.?

    I have tried debugging using SES and I could see the httpc.headers field was getting correct header string from the command. I stopped the program just before calling http_client_req() function. Here is the snapshot from debugging window:

     

    I can see the method, and header fields of the HTTP request are traversed by the application correctly.

    I would appreciate any insight on this.

    Regards,

    Shivek

  • Hello Shivek,

    Shivek said:
    Would you be able to send me some example having more than one header fields as in my case, i.e., authentication, host etc.?

    Unfortunately, we currently do not have more examples than what is given in the documentation for the SLM application. 

    Shivek said:
    I have tried debugging using SES and I could see the httpc.headers field was getting correct header string from the command. I stopped the program just before calling http_client_req() function. Here is the snapshot from debugging window:

    From the picture I can see that you still have the HTTP/1.1 in the string. As you can see in chapter 5.1, the HTTP/1.1 should be HTTP-Version, not a part of Request-URI.

    Regarding your Request-URI: /instruments/150771004/temperature-values/?page=1 looks more like a webpage instead of a resource to me. Is this some kind of a SQL statement, maybe?

    Regards,

    Markus

  • Hi Markus,

    I have tried many things with this and after debugging I found that HTTP/1.1 should not be there as APIs are hard coded to do that. So, I tried sending the command without HTTP/1.1 in the resource field, but didn't work.

    I am still not convinced about the documentation on the SLM proprietary commands. Would you be so kind to ask your team to document that with detailed examples?

    Another thing that I have tried is the example for POST command shown in this link with optional header fields i.e., content type, content length etc., and I am trying to send the commands through LTE Link Monitor. I configured the UART silence time to 10 sec so that it will listen to UART while I am copying the payload after I am getting 

    #XHTTPREQ:  1

    response from the APIs. But still its not working.

    Thanks for your response.

    Regards,

    Shivek

  • Shivek said:
    I am still not convinced about the documentation on the SLM proprietary commands. Would you be so kind to ask your team to document that with detailed examples?

    We are working on improving our documentation for the Serial LTE modem application.

    Shivek said:

    Another thing that I have tried is the example for POST command shown in this link with optional header fields i.e., content type, content length etc., and I am trying to send the commands through LTE Link Monitor. I configured the UART silence time to 10 sec so that it will listen to UART while I am copying the payload after I am getting 

    #XHTTPREQ:  1

    response from the APIs. But still its not working.

    I guess you mean the PUT command and are referring to this example? When using it, the answer you received (meaning: "1 - Wait for payload data") is correct, since you are supposed to post the payload data afterwards.

    Regards,

    Markus

  • Hi Markus,

    I am still not getting this done just because there are things that are not clear to me regarding format of the SLM specific commands. 

    Another thing is AT#HTTPCREQ is working for me, when I am using only one header field ending with <CR> <LF>. When I am using multiple header fields ending with <CR> <LF>, its not working for me.

    This is directing to the problem regarding how SLM interprets the data. So, it is very important to know the format. Again, I am requesting you to ask engineer and let me know the proper format I need to follow.

    Thanks for your efforts.

    Regards,

    Shivek

Related