400 ERROR - Bad Request
Posted: Tue May 10, 2022 8:38 pm
Hello,
I am trying to upload a PDF document to a REST api - sandbox as mentioned here https://apimarketplace.uhcprovider.com/ ... attachment
it works in SoapUI and using python on iSeries. However, I am getting Bad Request when I am consuming using HTTPAPI.
Here is the debug log:
Protocol Used: TLS Version 1.3
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 /Claims/api/attachment/v1.0?tin=%00%C2%97123456&transactionId=%00%C2%8711111-11111-11111-111&docTypeCode=%00%02&docTypeDesc=%00%08Support+Data+for+Cla&ticketNumber=%00%0CPIQ-123456 HTTP/1.1
Host: apimarketplace.uhcprovider.com
User-Agent: http-api/1.45
Content-Type: multipart/form-data
Content-Length: 113210
Authorization:
env:
Accept-Encoding:gzip,deflate
Content-Disposition: form-data; name="files"; filename="/tmp/UHC API Marketplace pdf.pdf"
sendraw(): entered
%PDF-1.4
%Óëéá
1 0 obj
<</Creator (Mozilla/5.0 \(Windows NT 10.0; Win64; x64\) AppleWebKit/537.36 \(KHTML, like Gecko\) Chrome/101.0.4951.54 Safari/537.36)
/Producer (Skia/PDF m101)
/CreationDate (D:20220509025312+00'00')
/ModDate (D:20220509025312+00'00')>>
endobj
3 0 obj
<</ca 1
/BM /Normal>>
endobj
5 0 obj
<</Type /XObject
/Subtype /Image
/Width 2348
/Height 159
/ColorSpace /DeviceGray
/BitsPerComponent 8
/Filter /DCTDecode
/ColorTransform 0
.......................lot of pdf data..............
trailer
<</Size 63
/Root 38 0 R
/Info 1 0 R>>
startxref
111872
%%EOF
recvresp(): entered
HTTP/1.1 400 Bad Request
Server: CloudFront
Date: Tue, 10 May 2022 20:22:40 GMT
Content-Type: text/html
Content-Length: 915
Connection: close
X-Cache: Error from cloudfront
Via: 1.1 b02b0d001663966fda1c9117bcb43836.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: DFW55-C3
X-Amz-Cf-Id: zWkdS1Ah4XxWdGfz8bPp43hv-YypG3qskpMgDs74_wD4dbJ780MZBw==
SetError() #13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 915
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 915 bytes.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>400 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: zWkdS1Ah4XxWdGfz8bPp43hv-YypG3qskpMgDs74_wD4dbJ780MZBw==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
SetError() #13: HTTP/1.1 400 Bad Request
http_close(): entered
RPG code:
//*---------------------------------------------------------------
//*MAIN
//*---------------------------------------------------------------
// *entry/entry parameters
dcl-pi *n;
end-pi;
//..consume REST Api.
//...testing
http_debug(*on:'/tmp/uhc_api.txt');
gPayerId = '12345678';
gTin = '12345678';
gClaimNumber = '12345678';
gBearerToken = '';
gContentType = 'text/plain';
getClaimDetailDS.transactionId = '11111-11111-11111-11111';
getDocListDs.documentList(1).docTypeCode = 'OT';
getDocListDs.documentList(1).docTypeDesc = 'Support Data for Claim';
getClaimActionDS.actions(1).ticketInfo(1).ticketNumber = 'PIQ-12345678';
//...testing
gUrl = 'https://apimarketplace.uhcprovider.com/ ... hment/v1.0?';
//..encode and add the parameters to the URL.
gvEncoder = http_url_encoder_new();
http_url_encoder_addvar( gvEncoder
: 'tin'
: %addr(gTin)
: %len(%trimr(gTin)) );
http_url_encoder_addvar( gvEncoder
: 'transactionId'
: %addr(getClaimDetailDS.transactionId)
: %len(%trimr(getClaimDetailDS.transactionId)) );
http_url_encoder_addvar( gvEncoder
: 'docTypeCode'
: %addr(getDocListDs.documentList(1).docTypeCode)
: %len(%trimr(getDocListDs.documentList(1).docTypeCode)) );
http_url_encoder_addvar( gvEncoder
: 'docTypeDesc'
: %addr(getDocListDs.documentList(1).docTypeDesc)
: %len(%trimr(getDocListDs.documentList(1).docTypeDesc)) );
http_url_encoder_addvar( gvEncoder
: 'ticketNumber'
: %addr(getClaimActionDS.actions(1).ticketInfo(1).ticketNumber)
: %len(%trimr(
getClaimActionDS.actions(1).ticketInfo(1).ticketNumber))
);
gUrl = %trim(gUrl) + http_url_encoder_getstr(gvEncoder);
http_url_encoder_free(gvEncoder);
http_xproc( HTTP_POINT_ADDL_HEADER
: %paddr(HeaderProc) );
// RequestStr = jsonData ;
// ResponseStr = http_string('POST' : gUrl : RequestStr : 'application/json') ;
//Set CCSID
// http_SetCCSIDs(1208:0);
// HTTP_SetFileCCSID(819) ;
rc = HTTP_req('POST' : %trim(gUrl) : *omit : ResponseStr
:'/tmp/UHC API Marketplace pdf.pdf'
: *omit
: 'multipart/form-data'
) ;
*inlr = *on;
return ;
I am trying to upload a PDF document to a REST api - sandbox as mentioned here https://apimarketplace.uhcprovider.com/ ... attachment
it works in SoapUI and using python on iSeries. However, I am getting Bad Request when I am consuming using HTTPAPI.
Here is the debug log:
Protocol Used: TLS Version 1.3
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 /Claims/api/attachment/v1.0?tin=%00%C2%97123456&transactionId=%00%C2%8711111-11111-11111-111&docTypeCode=%00%02&docTypeDesc=%00%08Support+Data+for+Cla&ticketNumber=%00%0CPIQ-123456 HTTP/1.1
Host: apimarketplace.uhcprovider.com
User-Agent: http-api/1.45
Content-Type: multipart/form-data
Content-Length: 113210
Authorization:
env:
Accept-Encoding:gzip,deflate
Content-Disposition: form-data; name="files"; filename="/tmp/UHC API Marketplace pdf.pdf"
sendraw(): entered
%PDF-1.4
%Óëéá
1 0 obj
<</Creator (Mozilla/5.0 \(Windows NT 10.0; Win64; x64\) AppleWebKit/537.36 \(KHTML, like Gecko\) Chrome/101.0.4951.54 Safari/537.36)
/Producer (Skia/PDF m101)
/CreationDate (D:20220509025312+00'00')
/ModDate (D:20220509025312+00'00')>>
endobj
3 0 obj
<</ca 1
/BM /Normal>>
endobj
5 0 obj
<</Type /XObject
/Subtype /Image
/Width 2348
/Height 159
/ColorSpace /DeviceGray
/BitsPerComponent 8
/Filter /DCTDecode
/ColorTransform 0
.......................lot of pdf data..............
trailer
<</Size 63
/Root 38 0 R
/Info 1 0 R>>
startxref
111872
%%EOF
recvresp(): entered
HTTP/1.1 400 Bad Request
Server: CloudFront
Date: Tue, 10 May 2022 20:22:40 GMT
Content-Type: text/html
Content-Length: 915
Connection: close
X-Cache: Error from cloudfront
Via: 1.1 b02b0d001663966fda1c9117bcb43836.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: DFW55-C3
X-Amz-Cf-Id: zWkdS1Ah4XxWdGfz8bPp43hv-YypG3qskpMgDs74_wD4dbJ780MZBw==
SetError() #13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 915
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 915 bytes.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>400 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: zWkdS1Ah4XxWdGfz8bPp43hv-YypG3qskpMgDs74_wD4dbJ780MZBw==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
SetError() #13: HTTP/1.1 400 Bad Request
http_close(): entered
RPG code:
//*---------------------------------------------------------------
//*MAIN
//*---------------------------------------------------------------
// *entry/entry parameters
dcl-pi *n;
end-pi;
//..consume REST Api.
//...testing
http_debug(*on:'/tmp/uhc_api.txt');
gPayerId = '12345678';
gTin = '12345678';
gClaimNumber = '12345678';
gBearerToken = '';
gContentType = 'text/plain';
getClaimDetailDS.transactionId = '11111-11111-11111-11111';
getDocListDs.documentList(1).docTypeCode = 'OT';
getDocListDs.documentList(1).docTypeDesc = 'Support Data for Claim';
getClaimActionDS.actions(1).ticketInfo(1).ticketNumber = 'PIQ-12345678';
//...testing
gUrl = 'https://apimarketplace.uhcprovider.com/ ... hment/v1.0?';
//..encode and add the parameters to the URL.
gvEncoder = http_url_encoder_new();
http_url_encoder_addvar( gvEncoder
: 'tin'
: %addr(gTin)
: %len(%trimr(gTin)) );
http_url_encoder_addvar( gvEncoder
: 'transactionId'
: %addr(getClaimDetailDS.transactionId)
: %len(%trimr(getClaimDetailDS.transactionId)) );
http_url_encoder_addvar( gvEncoder
: 'docTypeCode'
: %addr(getDocListDs.documentList(1).docTypeCode)
: %len(%trimr(getDocListDs.documentList(1).docTypeCode)) );
http_url_encoder_addvar( gvEncoder
: 'docTypeDesc'
: %addr(getDocListDs.documentList(1).docTypeDesc)
: %len(%trimr(getDocListDs.documentList(1).docTypeDesc)) );
http_url_encoder_addvar( gvEncoder
: 'ticketNumber'
: %addr(getClaimActionDS.actions(1).ticketInfo(1).ticketNumber)
: %len(%trimr(
getClaimActionDS.actions(1).ticketInfo(1).ticketNumber))
);
gUrl = %trim(gUrl) + http_url_encoder_getstr(gvEncoder);
http_url_encoder_free(gvEncoder);
http_xproc( HTTP_POINT_ADDL_HEADER
: %paddr(HeaderProc) );
// RequestStr = jsonData ;
// ResponseStr = http_string('POST' : gUrl : RequestStr : 'application/json') ;
//Set CCSID
// http_SetCCSIDs(1208:0);
// HTTP_SetFileCCSID(819) ;
rc = HTTP_req('POST' : %trim(gUrl) : *omit : ResponseStr
:'/tmp/UHC API Marketplace pdf.pdf'
: *omit
: 'multipart/form-data'
) ;
*inlr = *on;
return ;