[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] Error: Duplicate Header on HTTP_URL_POST



Hi Don,

Try using the following-
http_xproc(HTTP_POINT_ADDL_HEADER: *null)

Regards,
Shubhadeep Roy

On Sun, Jun 2, 2019 at 11:13 PM Don Brown <DBrown@xxxxxxxxxx> wrote:
I am getting an error on a POST - Duplicate Header

The process requires a GET to retrieve a Token and then a POST to send the transaction json data.

In the debug log I can see multiple Content-Type header lines.

In testing I had multiple calls to http_xproc( HTTP_POINT_ADDL_HEADER  so I removed all but one call to set the authentication details and I still get this duplicate error.

Is there a way to reset the headers like xproc( HTTP_POINT_ADDL_HEADER_CLEAR)  ???

Below is the code and the debug log.

Any suggestions very welcome.



SetError() #0:                                                                                                        
{"fault":{"faultstring":"Duplicate Header \"Content-Type\"","detail":{"errorcode":"protocol.http.DuplicateHeader"}}}  
SetError() #13: HTTP/1.1 400 Bad Request                                                                              
http_close(): entered                                                                                                

I am using the following to set my headers;

http_xproc( HTTP_POINT_ADDL_HEADER  
            : %paddr(tripHeaders) );


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                      

Here is the actual code;

   aaaaa.access_Token = '7ewaNweVb0Y5Odu8ikSaAfZjkoqA' ;                
   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", +                          
                       "tripStartPostcode": "2000", +            
                       "tripStartSuburb": "SYDNEY", +            
                       "tripAmount": "20.30" +                  
                       } +                                      
                        ] +                                      
                      } +                                        
                     }' ;                                        
                                                                 
       http_xproc( HTTP_POINT_ADDL_HEADER                        
                   : %paddr(tripHeaders) );                      
                                                                 
    uri = *blanks;                                              
    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) ;                        
    if (rc <> 1);                                                
      http_crash();                                              
    endif;                                                              

The debug log has the following;

 ************Beginning of data**************                                        
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                                                                
-------------------------------------------------------------------------------------
Dump of local-side certificate information:                                          
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
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                                  
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", "submittedDateTo": "01/02/2018 05:12:56 PM", "vehicleRegistrat
recvresp(): entered                                                                                                                
HTTP/1.1 400 Bad Request                                                                                                            
Date: Sat, 16 Feb 2019 05:58:07 GMT                                                                                                
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                              
 ************End of Data********************      

Don Brown

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi


--

Warm regards,
Shubh
All is well. Everything will be OK!!! - Shubh
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi