401 - Bad Request on DELETE

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
kathan.p@gmail.com
Posts: 19
Joined: Wed Aug 04, 2021 7:27 pm

401 - Bad Request on DELETE

Post by kathan.p@gmail.com »

Hi, Since yesterday suddenly http_string('DELETE') started giving HTTP 401 Bad Request..

Code: Select all

   HTTP_debug(*on);                    
   http_setCCSIDs( 1208: 0 );      
   HTTP_SetFileCCSID(1208);        
   
     http_xproc( HTTP_POINT_ADDL_HEADER   
              : %paddr(add_headers) ); 
              
        server = %trim(pltinturl) + %trim(pltitjobep) + jobid;      
        monitor;    
               response = http_string('DELETE': server);  
 on-error;                                  
  errorMsg = http_error();                  
   endmon;  

Server variable = Url with JOB id which will delete the data from site.
add_headers - this will get the bearer token saved on the system and attach to header.

whenever it tries to do DELETE it will give us BAD REQUEST
so later on as a fix we started creating new bearer token every time a DELETE is request and it worked. I know this is not the correct solution but it worked.
We are using DELETE on other client servers as well with same method and it's working fine no issues but for this particular server it started happening yesterday only and there was no PTF or any change on the server.

any advise why DELETE is suddenly started giving BAD REquest and after generating token on every request it resolved.

Code: Select all

HTTPAPI Ver 1.40 released 2019-08-15                                        
NTLM Ver 1.4.0 released 2014-12-22                                          
OS/400 Ver V7R2M0                                                           
                                                                            
New iconv() objects set, PostRem=1208. PostLoc=0. ProtRem=819. ProtLoc=0    
Protocol Used: TLS Version 1.2                                             
http_persist_req(DELETE) entered.                                          
http_long_ParseURL(): entered                                              
http_long_ParseURL(): entered                                              
do_oper(DELETE): entered                                                   
There are 0 cookies in the cache                                           
DELETE /api/jobs/8763308-01/?id_type=external     HTTP/1.1                 
Host: wei.pltsci.com                                                       
User-Agent: http-api/1.39                                                  
api-version: 2.0                                                           
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjZmZmNjN
  recvresp(): entered                                          
HTTP/1.1 400 Bad Request                                     
Server: awselb/2.0                                           
Date: Wed, 24 Nov 2021 21:38:44 GMT                          
Content-Type: text/html                                      
Content-Length: 122                                          
Connection: close                                            
                                                             
                                                             
SetError() #13: HTTP/1.1 400 Bad Request                     
recvresp(): end with 400                                     
recvdoc parms: identity 122                                  
header_load_cookies() entered                                
recvdoc(): entered                                           
SetError() #0:                                               
recvdoc(): Receiving 122 bytes.                              
recvdoc(): entered                                     
SetError() #0:                                         
recvdoc(): Receiving 122 bytes.                        
<html>                                                 
<head><title>400 Bad Request</title></head>            
<body>                                                 
<center><h1>400 Bad Request</h1></center>              
</body>                                                
</html>                                                
                                                       
SetError() #13: HTTP/1.1 400 Bad Request               
http_close(): entered                                                                                                                                                       
 
Scott Klement
Site Admin
Posts: 670
Joined: Sun Jul 04, 2021 5:12 am

Re: 401 - Bad Request on DELETE

Post by Scott Klement »

I can see that there is something strange about both your URL and your bearer token. Please verify that these do not have extra spaces or other unprintable characters in them.
kathan.p@gmail.com
Posts: 19
Joined: Wed Aug 04, 2021 7:27 pm

Re: 401 - Bad Request on DELETE

Post by kathan.p@gmail.com »

This was resolved, it was an issue while doing handshake ... thank you
Post Reply