13 HTTP/1.1 202 Accepted - Attempting to post
Posted: Thu Sep 16, 2021 4:12 am
I am trying to post an entry to a GreyLog syslog server.
I can successfully post a log using curl from a strqsh session - see example below.
But when I try using the HTTPAPI Command it fails which I was using for a quick test and perhaps is a limitation of the command ??
This works
The following commands are run before starting qsh
ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y)
ADDENVVAR ENVVAR(QIBM_MULTI_THREADED) VALUE(Y)
strqsh
/QOpenSys/pkgs/bin/curl -X POST -H 'Content-Type: application/json' -d '{ "version": "1.1", "host": "example.org", "short_message
": "Testing from QSH using Curl", "level": 5, "_some_info": "foo" }' 'http://Bnelog1.isuzu.local:12201/gelf'
$
The $ tells me no error was detected and the entry does appear in the syslog server
But using HTTPAPI Command no entry is received in the syslog server
HTTPAPI URL('http://Bnelog1.xxxxxx.local:12201/gelf') DOWNLOAD('/home/msd/result.txt')
REQTYPE(*POST) UPLOAD('/home/msd/syslog.txt') TYPE('application/json') DEBUG('/home/msd/debug.txt')
13 HTTP/1.1 202 Accepted
The syslog.txt contains
************Beginning of data**************
-d '{ "short_message": "This is a short message", "full_message":"This is th efull message ", "host":"Hostname", "version":"Version
", "timestamp": "1629332852.490", "level": "01" }'
************End of Data********************
The result.txt is empty
The debug.txt contains
************Beginning of data**************
HTTPAPI Ver 1.42 released 2020-10-12
NTLM Ver 1.4.0 released 2014-12-22
OS/400 Ver V7R3M0
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: XXXXX.LOCAL
DNS server found: 192.168.126.2
DNS server found: 192.168.126.3
DNS server found: 10.100.0.210
Nagle's algorithm (TCP_NODELAY) disabled.
http_persist_post(): entered
http_persist_req(POST) entered.
http_long_ParseURL(): entered
http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /gelf HTTP/1.1
Host: Bnelog1.xxxxx.local:12201
User-Agent: http-api/1.43
Content-Type: application/json
Content-Length: 182
sendraw(): entered
-d '{ "short_message": "This is a short message", "full_message":"This is th efull message ", "host":"Hostname", "version":"Version", "timestamp": "1629332852.490", "level": "01" }'
recvresp(): entered
HTTP/1.1 202 Accepted
content-length: 0
connection: keep-alive
SetError() #13: HTTP/1.1 202 Accepted
recvresp(): end with 202
recvdoc parms: identity 0
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 0 bytes.
recvdoc(): Nothing to receive, exiting...
SetError() #13: HTTP/1.1 202 Accepted
http_close(): entered
************End of Data********************
Any suggestions appreciated.
I can successfully post a log using curl from a strqsh session - see example below.
But when I try using the HTTPAPI Command it fails which I was using for a quick test and perhaps is a limitation of the command ??
This works
The following commands are run before starting qsh
ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y)
ADDENVVAR ENVVAR(QIBM_MULTI_THREADED) VALUE(Y)
strqsh
/QOpenSys/pkgs/bin/curl -X POST -H 'Content-Type: application/json' -d '{ "version": "1.1", "host": "example.org", "short_message
": "Testing from QSH using Curl", "level": 5, "_some_info": "foo" }' 'http://Bnelog1.isuzu.local:12201/gelf'
$
The $ tells me no error was detected and the entry does appear in the syslog server
But using HTTPAPI Command no entry is received in the syslog server
HTTPAPI URL('http://Bnelog1.xxxxxx.local:12201/gelf') DOWNLOAD('/home/msd/result.txt')
REQTYPE(*POST) UPLOAD('/home/msd/syslog.txt') TYPE('application/json') DEBUG('/home/msd/debug.txt')
13 HTTP/1.1 202 Accepted
The syslog.txt contains
************Beginning of data**************
-d '{ "short_message": "This is a short message", "full_message":"This is th efull message ", "host":"Hostname", "version":"Version
", "timestamp": "1629332852.490", "level": "01" }'
************End of Data********************
The result.txt is empty
The debug.txt contains
************Beginning of data**************
HTTPAPI Ver 1.42 released 2020-10-12
NTLM Ver 1.4.0 released 2014-12-22
OS/400 Ver V7R3M0
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: XXXXX.LOCAL
DNS server found: 192.168.126.2
DNS server found: 192.168.126.3
DNS server found: 10.100.0.210
Nagle's algorithm (TCP_NODELAY) disabled.
http_persist_post(): entered
http_persist_req(POST) entered.
http_long_ParseURL(): entered
http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /gelf HTTP/1.1
Host: Bnelog1.xxxxx.local:12201
User-Agent: http-api/1.43
Content-Type: application/json
Content-Length: 182
sendraw(): entered
-d '{ "short_message": "This is a short message", "full_message":"This is th efull message ", "host":"Hostname", "version":"Version", "timestamp": "1629332852.490", "level": "01" }'
recvresp(): entered
HTTP/1.1 202 Accepted
content-length: 0
connection: keep-alive
SetError() #13: HTTP/1.1 202 Accepted
recvresp(): end with 202
recvdoc parms: identity 0
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 0 bytes.
recvdoc(): Nothing to receive, exiting...
SetError() #13: HTTP/1.1 202 Accepted
http_close(): entered
************End of Data********************
Any suggestions appreciated.