Quectel EC20 customize header for http get request

Hi Team,
How to customize header when http get request with AT+QHTTPCFG=“requestheader”,1?

Dear Linh,
Thanks for your inquiry in Quectel forum.
Please check the document which already explain how to customize header. Thanks!
Quectel_LTE_Standard_HTTP(S)_Application_Note_V1.1.pdf (394.7 KB)

Hi Kyson,
Document only show about customize header for POST http request, with header send in body. But I need customize header when send GET request. My REST API need add token in header when send request, pls help me. !

Please check the document. Thanks!

Thank for your guidance, Kyson !

Hi, thanks for your reply.

as per your suggestion, I had try this but not able to getting work.

pls check below log and let me know what are the issue, as i am not able to re-solve the issue.

i need to add 2 header 1) content type and 2) auth parameter. i had try with content type only.

AT+CSQ
+CSQ: 21,99
OK

AT+QIACT?
+QIACT: 1,1,1,"10.54.170.106"
OK

AT+QHTTPCFG="contextid",1
OK

AT+QHTTPCFG="requestheader",1
OK

AT+QHTTPURL=73,150
CONNECT
http://pdpqadevicesync.orbitron.in:8080/v1/DeviceActivitySync/GetDateTime
OK

AT+QHTTPGET=150,34,60<CR><LF>
CONNECT
Content-Type: application/json<CR><LF>
<CR><LF>
OK
+QHTTPGET: 0,400,326

AT+QHTTPREAD=60
CONNECT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><CR><LF>
<HTML><HEAD><TITLE>Bad Request</TITLE><CR><LF>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD><CR><LF>
<BODY><h2>Bad Request - Invalid Verb</h2><CR><LF>
<hr><p>HTTP Error 400. The request verb is invalid.</p><CR><LF>
</BODY></HTML><CR><LF>
<CR><LF>
OK

looking forward for your help…

Thanks

Hi Ashvin,
Here example for you:
AT+QHTTPURL=73,150
CONNECT
http://pdpqadevicesync.orbitron.in
OK

AT+QHTTPGET=150,34,60
CONNECT
GET /v1/DeviceActivitySync/GetDateTime HTTP/1.1
Host: pdpqadevicesync.orbitron.in
Content-Type: application/json
OK

1 Like

Thanks for your sharing. Thanks!

Hi,
Thanks for your contribution,

i had which you had suggested, but not getting response data.
pls check below response which i get in terminal.as per datasheet it show that “Time Out error : 702” , " Socket Close : 719".

also some time get +CMTI: “ME”,1

AT+QHTTPURL=39,150<CR><LF>

<CR><LF>
CONNECT<CR><LF>

http://pdpqadevicesync.orbitron.in:8080
<CR><LF>
OK<CR><LF>

AT+QHTTPGET=150,140,60<CR><LF>

<CR><LF>
CONNECT<CR><LF>

GET /v1/DeviceActivitySync/GetDateTime HTTP/1.1<CR><LF>
Host: pdpqadevicesync.orbitron.in<CR><LF>
Content-Type: application/json<CR><LF>
Connection: keep-alive<CR><LF>

<CR><LF>
OK<CR><LF>
<CR><LF>
+QHTTPGET: 702<CR><LF>

AT+QHTTPGET=150,140,60<CR><LF>

<CR><LF>
CONNECT<CR><LF>

GET /v1/DeviceActivitySync/GetDateTime HTTP/1.1<CR><LF>
Host: pdpqadevicesync.orbitron.in<CR><LF>
Content-Type: application/json<CR><LF>
Connection: keep-alive<CR><LF>

<CR><LF>
OK<CR><LF>
<CR><LF>
+QHTTPGET: 719<CR><LF>

Change header to
Host: pdpqadevicesync.orbitron.in:8080

1 Like

Hi,
i had try suggested changes with 2 different server 1) pdpqadevicesync.orbitron.in (our hosting) 2) ptsv2.com (global method test platform), but i got same error in both server.

pls check below response, tested with both server.


11/20/2020 11:12:12.714 [TX] - AT+QIACT?<CR><LF>

11/20/2020 11:12:12.719 [RX] - <CR><LF>
+QIACT: 1,1,1,"10.54.180.209"<CR><LF>
<CR><LF>
OK<CR><LF>

11/20/2020 11:12:20.056 [TX] - AT+QHTTPCFG="contextid",1<CR><LF>

11/20/2020 11:12:20.061 [RX] - <CR><LF>
OK<CR><LF>

11/20/2020 11:12:23.673 [TX] - AT+QHTTPCFG="requestheader",1<CR><LF>

11/20/2020 11:12:23.676 [RX] - <CR><LF>
OK<CR><LF>

11/20/2020 11:12:28.858 [TX] - AT+QHTTPURL=39,150<CR><LF>

11/20/2020 11:12:28.863 [RX] - <CR><LF>
CONNECT<CR><LF>

11/20/2020 11:12:31.690 [TX] - http://pdpqadevicesync.orbitron.in:8080
11/20/2020 11:12:31.693 [RX] - <CR><LF>
OK<CR><LF>

11/20/2020 11:12:35.633 [TX] - AT+QHTTPGET=150,121,60<CR><LF>

11/20/2020 11:12:36.147 [RX] - <CR><LF>
CONNECT<CR><LF>

11/20/2020 11:12:39.153 [TX] - GET /v1/DeviceActivitySync/GetDateTime HTTP/1.1<CR><LF>
Host: pdpqadevicesync.orbitron.in:8080<CR><LF>
Content-Type: application/json<CR><LF>

11/20/2020 11:12:39.155 [RX] - <CR><LF>
OK<CR><LF>

11/20/2020 11:15:05.642 [RX] - <CR><LF>
+QHTTPGET: 702<CR><LF>

11/20/2020 11:15:19.745 [TX] - AT+QIACT?<CR><LF>

11/20/2020 11:15:19.751 [RX] - <CR><LF>
+QIACT: 1,1,1,"10.54.180.209"<CR><LF>
<CR><LF>
OK<CR><LF>

11/20/2020 11:18:10.890 [TX] - AT+QHTTPURL=16,150<CR><LF>

11/20/2020 11:18:10.895 [RX] - <CR><LF>
CONNECT<CR><LF>

11/20/2020 11:18:12.818 [TX] - http://ptsv2.com
11/20/2020 11:18:12.821 [RX] - <CR><LF>
OK<CR><LF>

11/20/2020 11:18:16.354 [TX] - AT+QHTTPGET=150,88,60<CR><LF>

11/20/2020 11:18:16.571 [RX] - <CR><LF>
CONNECT<CR><LF>

11/20/2020 11:18:18.682 [TX] - GET /t/0pqh7-1605078077/post HTTP/1.1<CR><LF>
Host: ptsv2.com<CR><LF>
Content-Type: application/json<CR><LF>

11/20/2020 11:18:18.683 [RX] - <CR><LF>
OK<CR><LF>

11/20/2020 11:20:46.368 [RX] - <CR><LF>
+QHTTPGET: 702<CR><LF>

11/20/2020 11:23:30.457 [TX] - AT+GMR<CR><LF>

11/20/2020 11:23:30.460 [RX] - <CR><LF>
EC25EFAR02A08M4G<CR><LF>
<CR><LF>
OK<CR><LF>

11/20/2020 11:23:45.251 [TX] - AT+QIACT?<CR><LF>

11/20/2020 11:23:45.254 [RX] - <CR><LF>
+QIACT: 1,1,1,"10.54.180.209"<CR><LF>
<CR><LF>
OK<CR><LF>

I tested with EC20 module:

[2020-11-20_14:51:50:312]AT+QHTTPCFG=“contextid”,1

[2020-11-20_14:51:50:313]OK
[2020-11-20_14:51:51:721]AT+QHTTPCFG=“requestheader”,1

[2020-11-20_14:51:51:721]OK
[2020-11-20_14:51:54:107]AT+QHTTPURL=39,150

[2020-11-20_14:51:54:113]CONNECT
[2020-11-20_14:51:55:479]
[2020-11-20_14:51:55:479]OK
[2020-11-20_14:51:57:194]AT+QHTTPGET=60,123,60

[2020-11-20_14:51:59:013]CONNECT
[2020-11-20_14:52:05:368]
[2020-11-20_14:52:05:368]OK
[2020-11-20_14:52:05:530]
[2020-11-20_14:52:05:530]+QHTTPGET: 0,200,21
[2020-11-20_14:52:07:326]AT+QHTTPREAD=60

[2020-11-20_14:52:07:326]CONNECT
[2020-11-20_14:52:07:326]“20-11-2020-13-22-05”
[2020-11-20_14:52:07:326]OK

[2020-11-20_14:52:07:326]+QHTTPREAD: 0

your problem at this line -->AT+QHTTPGET=150,121,60

Actual length is 123, include \r\n at bottom of header.

1 Like

Hi.

thanks you, for your help.

I have tested and it’s working now.

I forget additional \r\n at end of header

Thanks

please give the full AT commands to trigger the web socket

GET /steve/websocket/CentralSystemService/dummyCP001 HTTP/1.1
Host: 13.233.136.157:8080
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: ocpp2.0, ocpp1.6
Sec-WebSocket-Version: 13

1 Like

Hi [gopal367reddy],
I think TCP/IP AT better for this case, after server response, client and server can speak normal via TCP/IP. EXAMPLE FOR HTTP AT AND TCP SHOW BLOW:

[2020-12-25_14:48:25:513]AT+QICSGP=1,1,“v-internet”,"","" ,0
[2020-12-25_14:48:25:515]OK
[2020-12-25_14:48:27:116]AT+QIACT=1
[2020-12-25_14:48:27:301]OK
[2020-12-25_14:48:28:459]AT+QIACT?
[2020-12-25_14:48:28:461]+QIACT: 1,1,1,“11.58.6.30”
[2020-12-25_14:48:28:461]OK
[2020-12-25_14:48:46:654]AT+QIOPEN=1,0,“TCP”,“13.233.136.157”,8080,0,1
[2020-12-25_14:48:46:656]OK
[2020-12-25_14:48:46:920]
[2020-12-25_14:48:46:920]+QIOPEN: 0,0
[2020-12-25_14:48:48:737]AT+QISEND=0,283
[2020-12-25_14:48:48:739]> GET /steve/websocket/CentralSystemService/dummyCP001 HTTP/1.1
[2020-12-25_14:48:55:340]Host: 13.233.136.157:8080
[2020-12-25_14:48:55:340]Upgrade: websocket
[2020-12-25_14:48:55:340]Connection: Upgrade
[2020-12-25_14:48:55:340]Origin: http://13.233.136.157:8080
[2020-12-25_14:48:55:340]Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
[2020-12-25_14:48:55:340]Sec-WebSocket-Protocol: ocpp2.0, ocpp1.6
[2020-12-25_14:48:55:340]Sec-WebSocket-Version: 13
[2020-12-25_14:48:55:346]SEND OK
[2020-12-25_14:48:55:509]
[2020-12-25_14:48:55:509]+QIURC: “recv”,0,162
[2020-12-25_14:48:55:509]HTTP/1.1 101 Switching Protocols
[2020-12-25_14:48:55:509]Sec-WebSocket-Protocol: ocpp1.6
[2020-12-25_14:48:55:509]Connection: Upgrade
[2020-12-25_14:48:55:509]Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
[2020-12-25_14:48:55:509]Upgrade: WebSocket

[2020-12-25_15:00:03:945]AT+QICSGP=1,1,“v-internet”,"","" ,0
[2020-12-25_15:00:03:947]OK
[2020-12-25_15:00:04:702]AT+QIACT=1
[2020-12-25_15:00:04:867]OK
[2020-12-25_15:00:06:187]AT+QIACT?
[2020-12-25_15:00:06:189]+QIACT: 1,1,1,“11.225.159.100”
[2020-12-25_15:00:06:189]OK
[2020-12-25_15:00:10:704]AT+QHTTPCFG=“contextid”,1
[2020-12-25_15:00:10:704]OK
[2020-12-25_15:00:12:187]AT+QHTTPCFG=“requestheader”,1
[2020-12-25_15:00:12:187]OK
[2020-12-25_15:00:13:106]AT+QHTTPCFG=“responseheader”,1
[2020-12-25_15:00:13:106]OK
[2020-12-25_15:00:14:029]AT+QHTTPURL=26,60
[2020-12-25_15:00:14:029]CONNECT
[2020-12-25_15:00:14:987]
http://13.233.136.157:8080
[2020-12-25_15:00:14:987]OK
[2020-12-25_15:00:16:929]AT+QHTTPGET=60,283,60
[2020-12-25_15:00:17:172]CONNECT
[2020-12-25_15:00:18:286]
GET /steve/websocket/CentralSystemService/dummyCP001 HTTP/1.1
Host: 13.233.136.157:8080
Upgrade: websocket
Connection: Upgrade
Origin: http://13.233.136.157:8080
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: ocpp2.0, ocpp1.6
Sec-WebSocket-Version: 13
[2020-12-25_15:00:18:286]OK
[2020-12-25_15:00:18:533]
[2020-12-25_15:00:18:533]+QHTTPGET: 0,101
[2020-12-25_15:00:21:887]AT+QHTTPREAD=60
[2020-12-25_15:00:21:887]CONNECT
[2020-12-25_15:00:21:887]HTTP/1.1 101 Switching Protocols
[2020-12-25_15:00:21:887]Sec-WebSocket-Protocol: ocpp1.6
[2020-12-25_15:00:21:887]Connection: Upgrade
[2020-12-25_15:00:21:887]Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
[2020-12-25_15:00:21:887]Upgrade: WebSocket

@Linh_Bui Thanks for your sharing.

@Linh_Bui Thanks for your sharing


i am not getting response

HI MAN,
I check every thing is OK. I think you forgot \r\n at end of header.

Sec-WebSocket-Version: 13\r\n
\r\n

@Linh_Bui Hello Sir, Even I tried also with EC200 along with \r\n at the end of header also but not able to receive any response even after some time Response timeout is coming so please help me out…