Application/json post issues on HL7800

Having a bit of a struggle with trying to do a JSON post on the HL7800

Maybe you have an example of AT+httpheader for a post of application/json type?

We are using the HL7800 module to get/send data to a web service with HTTP get/post
The HTTP Get part works fine but the problem is HTTP POST

What we do is:

  • AT+KHTTPCFG=1,“www.someplace.com”,8888,0
  • AT+KHTTPHEADER=1 After we send “Content-Type: application/json” + RETURN. “–EOF–Pattern–” We get OK from module.
  • AT+KHTTPPOST=1,"/api/v1/hc" (we get CONNECT). After we send data.

It seems the server connection is working and the server gets some data, but something is wrong. We get “Bad Request” from the server and also server answer to us that “we are sending TEXT/PLAIN” data (you can see in the attached screenshot).

It seems that the command AT+KHTTPHEADER=1 is not working/is not accepted by the module.

Hi @Rique,
Here is the result I tried:

16:42:20.591 on 19-Feb-2020> at+khttpcfg?
16:42:29.917 on 19-Feb-2020>
16:42:29.917 on 19-Feb-2020> +KHTTPCFG: 1,1,“httpbin.org”,80,0,"","",0,0,0
16:42:29.917 on 19-Feb-2020>
16:42:29.917 on 19-Feb-2020> OK
16:42:29.917 on 19-Feb-2020> at+khttpheader?
16:42:43.986 on 19-Feb-2020>
16:42:43.986 on 19-Feb-2020> +KHTTPHEADER: 1,1
16:42:43.986 on 19-Feb-2020> Content-Type: application/json
16:42:43.997 on 19-Feb-2020>
16:42:43.997 on 19-Feb-2020>
16:42:43.998 on 19-Feb-2020> OK
16:42:43.998 on 19-Feb-2020> at+khttppost=1,"/post"
16:43:13.186 on 19-Feb-2020>
16:43:17.627 on 19-Feb-2020> +KCNX_IND: 1,4,1
16:43:17.627 on 19-Feb-2020>
16:43:17.627 on 19-Feb-2020> +CEREG: 4
16:43:17.627 on 19-Feb-2020>
16:43:17.628 on 19-Feb-2020> +CEREG: 5
16:43:17.628 on 19-Feb-2020>
16:43:17.628 on 19-Feb-2020> +KCNX_IND: 1,1,0
16:43:17.628 on 19-Feb-2020>
16:43:17.628 on 19-Feb-2020> +KHTTP_IND: 1,1
16:43:17.628 on 19-Feb-2020>
16:43:17.643 on 19-Feb-2020> CONNECT
16:43:17.643 on 19-Feb-2020> HTTP/1.1 200 OK
16:43:33.267 on 19-Feb-2020> date: Wed, 19 Feb 2020 09:43:18 GMT
16:43:33.314 on 19-Feb-2020> content-type: application/json
16:43:33.314 on 19-Feb-2020> content-length: 345
16:43:33.314 on 19-Feb-2020> connection: keep-alive
16:43:33.314 on 19-Feb-2020> server: gunicorn/19.9.0
16:43:33.314 on 19-Feb-2020> access-control-allow-origin: *
16:43:33.314 on 19-Feb-2020> access-control-allow-credentials: true

I recommend you:

  • Verify your module on httpbin.org with same above flow
  • Enable flow control by AT&K3. You will need to enable hardware flow control for the terminal as well
    Thanks

Thanks. A few questions.

  1. can we see the commands you use to set everything up? That seems to be mostly output
  2. We have only a 3 wire connection to the HL7800 from our processor. Is this an issue?

Hi Rique,
It is highly recommended to configure the module for hardware flow control using command AT&K3 but I tried on AT&K0 too, It works on both. Here is result I tried on a 3 wire connection to the HL7800.

at+khttpcfg=1,“httpbin.org

+KHTTPCFG: 1

OK

+KCNX_IND: 1,1,0

+KHTTP_IND: 1,1
at+khttpheader=1

CONNECT

Content-Type: application/json
–EOF–Pattern–

OK
at+khttppost=1,,"/post"

CONNECT
{
"id”:99999999,
“orders”:[
{
"ID”:8383838383,
“amount”:0,
“slotID”:36972026
},
{
"ID”:2929292929,
“amount”:0,
“slotID”:36972026
},
{
"ID”:4747474747,
“amount”:0,
“slotID”:36972026
}]
}
HTTP/1.1 200 OK
date: Thu, 20 Feb 2020 07:32:03 GMT
content-type: application/json
content-length: 345
connection: keep-alive
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true
–EOF–Pattern–

OK

+KHTTP_IND: 1,3,4,200,“OK”

2 Likes