Note: ftpapi@xxxxxxxxxxxxxxxxxxxxxx mailing list is still not operational.
I am having a problem where I am receiving the error of a Duplicate Header
The test program I am writing retrieves a token from a REST service and
then uses the authentication token to POST json data to the REST Service.
I am using http_xproc( HTTP_POINT_ADDL_HEADER to set the header
authentication details.
The request to retrieve the token succeeds but then I need to set new
headers to be able to POST the json data.
I can not find an option to Clear the header.
The debug log is showing two Content-Types and I think based on the error
message this is the reason for the error.
The code and debug log is below.
Hoping someone has come across this issue and can advise how to resolve
it.
Thanks
Relevant code snippet and Debug log follows;
uri = '
https://uat.api.onegov.nsw.gov.au/+
/oauth/client_credential/accesstoken+
?grant_type=client_credentials';
http_xproc( HTTP_POINT_ADDL_HEADER
: %paddr(tokenHeaders) );
rc = http_url_get(uri: jsonFileName );
if (rc <> 1);
http_crash();
endif;
Data-into aaaaa %Data( jsonFileName :
'doc=file case=convert countprefix=num_')
%Parser( 'YAJL72/YAJLINTO' );
myjsonTrips = '{ +
"rideshareDetail": +
{ +
"submittedDateFrom": "01/01/2018 05:12:12 AM", +
"submittedDateTo": "01/02/2018 05:12:56 PM", +
"vehicleRegistration": "test", +
"policyNumber": "", +
"ctpInsurer": "", +
"tripDetail": [ +
{ +
"tripId": "BBR1009", +
"tripStartDateTime": "02/01/2018 10:45:12 AM", +
"tripEndDateTime": "05/01/2018 12:45:12 PM", +
"tripDistance": "15", +
"tripStartPostcode": "2000", +
"tripStartSuburb": "SYDNEY", +
"tripAmount": "20.30" +
}, +
{ +
"tripId": "BBR1505", +
"tripStartDateTime": "07/01/2018 01:15:56 PM", +
"tripEndDateTime": "08/01/2018 02:30:00 PM", +
"tripDistance": "15", +
"tripDistance": "15", +
"tripStartPostcode": "2000", +
"tripStartSuburb": "SYDNEY", +
"tripAmount": "20.30" +
} +
] +
} +
}' ;
http_xproc( HTTP_POINT_ADDL_HEADER
: %paddr(tripHeaders) );
uri = '
https://uat.api.onegov.nsw.gov.au+
/P2PRideshare/v1/operator/tripdetails/submit';
rc = http_url_post(uri
: %addr(myjsontrips) + 2
: %len(%trim(myjsontrips))
: jsonfilename2) ;
P tokenHeaders B
D tokenHeaders PI
D Header 1024A varying
D UserData * value
/free
Header = 'Postman-Token: f6a0e906-b1cf-4e13-8da8-023274871bd4'
+ x'0d25'
+ ' apikey: WmTFrOi8ZXBa0RBn6Tx2vYd3dnkOgtjj'
+ x'0d25'
+ 'authorization: Basic +
V21URnJPaThaWEJhMFJCbjZUeDJ2WWQzZG5rT2d0amo6cnRUcjk5amtockNhV0Z0aA'
+ x'0d25'
+ 'cache-control: no-cache'
+ x'0d25';
/end-free
P E
P tripHeaders B
D tripHeaders PI
D Header 1024A varying
D UserData * value
/free
Header = 'Content-Type: application/json'
+ x'0d25'
+ 'Postman-Token: 5becf8a5-db3c-4cf7-8941-3d38e4b9343b'
+ x'0d25'
+ 'apikey: WmTFrOi8ZXBa0RBn6Tx2vYd3dnkOgtjj'
+ x'0d25'
+ 'authorization: Bearer ' + %trim(aaaaa.access_Token)
+ x'0d25'
+ 'transactionID: 22245678'
+ x'0d25'
+ 'requestTimeStamp: 04/06/2018 03:10:22 pm'
+ x'0d25'
+ 'cache-control: no-cache'
+ x'0d25'
+ 'userID: Don'
+ x'0d25';
/end-free
P E
Debug Log
HTTPAPI Ver 1.24 released 2012-01-23
OS/400 Ver V7R3M0
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_url_post(): entered
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: MSD.LOCAL
DNS server found: 10.1.1.31
DNS server found: 8.8.8.8
https_init(): entered
SetError() #49: SSL_protocol: Unknown protocol 596
Protocol Used:
http_persist_post(): entered
http_persist_req(POST) entered.
http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /P2PRideshare/v1/operator/tripdetails/submit HTTP/1.1
Host: uat.api.onegov.nsw.gov.au
User-Agent: http-api/1.24
Content-Type: text/xml
Content-Length: 644
Content-Type: application/json
Postman-Token: 5becf8a5-db3c-4cf7-8941-3d38e4b9343b
apikey: WmTFrOi8ZXBa0RBn6Tx2vYd3dnkOgtjj
authorization: Bearer 7ewaNweVb0Y5Odu8ikSaAfZjkoqA
transactionID: 22245678
requestTimeStamp: 04/06/2018 03:10:22 pm
cache-control: no-cache
userID: Don.Brown@xxxxxxxxxx
senddoc(): entered
{ "rideshareDetail": { "submittedDateFrom": "01/01/2018 05:12:12 AM",
recvresp(): entered
HTTP/1.1 400 Bad Request
Date: Sat, 16 Feb 2019 05:58:07 GMT
Content-Type: application/json
Content-Length: 116
Connection: keep-alive
X-Frame-Options: DENY
Strict-Transport-Security: max-age=86400
X-Content-Type-Options: nosniff
Content-Security-Policy: frame-ancestors 'none'
X-XSS-Protection: 1
SetError() #13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 116
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
{"fault":{"faultstring":"Duplicate Header
\"Content-Type\"","detail":{"errorcode":"protocol.http.DuplicateHeader"}}}
SetError() #13: HTTP/1.1 400 Bad Request
http_close(): entered
Don Brown
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit
http://www.symanteccloud.com
______________________________________________________________________
As an Amazon Associate we earn from qualifying purchases.