getting 411 error with POST having empty body or request is causing error

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
sgonchigar
Posts: 9
Joined: Tue May 10, 2022 4:46 pm

getting 411 error with POST having empty body or request is causing error

Post by sgonchigar »

Hello,

I am consuming a API that has no request body. There is just a query parameter.
RequestStr = '' ;
ResponseStr = '' ;
Url = https://......................?acknowledgementId=value
rc = http_req('POST': Url : *omit : ResponseStr : *omit: RequestStr :'application/json') ;

Above is resulting in 411 error. Any suggestions?

SetError() #13: HTTP/1.1 411 Length Required
recvresp(): end with 411
recvdoc parms: identity 344
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 344 bytes.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>

SetError() #13: HTTP/1.1 411 Length Required
http_close(): entered
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: getting 411 error with POST having empty body or request is causing error

Post by Scott Klement »

Why are you using a POST request if you have no data to send? Shouldn't it be a GET request?

That said, a POST should work, it should send Content-Length: 0. Is it not?
sgonchigar
Posts: 9
Joined: Tue May 10, 2022 4:46 pm

Re: getting 411 error with POST having empty body or request is causing error

Post by sgonchigar »

Yes. The Content-Length is not getting passed when the body is empty. Even I thought it should be a GET. The POST requirement doesn't have anything in the body. Just a query parameter.

This is the Curl example that was provided.
curl --location --request POST 'https://apimarketplace.uhc.com/Claims/a ... CD12345678' \ --header 'Authorization: ' \--header 'env: sandbox'
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: getting 411 error with POST having empty body or request is causing error

Post by Scott Klement »

Please try the current beta version from this link:
https://www.scottklement.com/httpapi/beta/

I made a quick bug fix that I think will help. I will need to know if it solves the problem for you, so I can release it to everyone else.
sgonchigar
Posts: 9
Joined: Tue May 10, 2022 4:46 pm

Re: getting 411 error with POST having empty body or request is causing error

Post by sgonchigar »

Thank you so much Scott. That worked.

I did have problem installing. Below 3 files were missing during the installation process. I was able to get around by copying from prior version.

File QRPGLESRC in library *LIBL with member NTLM_H not found.
File QRPGLESRC in library *LIBL with member ENCODERR4 not found.
File QRPGLESRC in library *LIBL with member DECODERR4 not found.

Also, when restored the sources were missing member text/description when viewed in PDM

Thank you!!
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: getting 411 error with POST having empty body or request is causing error

Post by Scott Klement »

Sorry about the missing members. I moved the source code to be stored in GitHub, and that was a bug in my tool to generate a library with source members (after pulling the code from GitHub.)

Would you mind trying again? Tell me if that problem is fixed.

You're right, there will be no text descriptions on the members -- that is expected right now (until I come up with a good solution for it.)
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: getting 411 error with POST having empty body or request is causing error

Post by Scott Klement »

I've also added back the text descriptions for the source members, now.
sgonchigar
Posts: 9
Joined: Tue May 10, 2022 4:46 pm

Re: getting 411 error with POST having empty body or request is causing error

Post by sgonchigar »

the missing member and member text issue is resolved. There were two new errors. I took "I" on both these.

570 - CRTPNLGRP PNLGRP(LIBHTTP/HTTPAPI) SRCFILE(*LIBL/QCMDSRC)
SRCMBR(HTTPAPIPNL)
Warning messages issued when panel group HTTPAPI created.
573 - DLTSPLF FILE(HTTPAPI) JOB(*) SPLNBR(*LAST)
578 - CRTCMD CMD(LIBHTTP/HTTPAPI) PGM(*LIBL/HTTPCMDR4)
SRCFILE(*LIBL/QCMDSRC) HLPPNLGRP(*LIBL/HTTPAPI) HLPID(*CMD)
PRDLIB(LIBHTTP)
Command HTTPAPI not created in library LIBHTTP.
Function check. CPF0201 unmonitored by INSTALL at statement 578,
instruction X'0629'.
CPF0201 received by INSTALL at 578. (C D I R)
CPF0201 received by INSTALL at 578. (C D I R)
...........
643 - CRTCMD CMD(LIBHTTP/EXAMPLE9) PGM(LIBHTTP/EXAMPLE9)
SRCFILE(*LIBL/QCMDSRC) PRDLIB(LIBHTTP)
Command EXAMPLE9 not created in library LIBHTTP.
Function check. CPF0201 unmonitored by INSTALL at statement 643,
instruction X'06EC'.
CPF0201 received by INSTALL at 643. (C D I R)
Post Reply