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

Re: [Ftpapi] Problem on subsequent calls



Hi Les,

Since I'm not familiar with this API, it's not clear what would cause this API to behave this way.

You mentioned clearing a cache.  You could consider clearing out some of the things you've set, for example, clear out the bearer token from memory by calling http_setAuth(HTTP_AUTH_NONE: '' : '') or clear out the additional headers by doing http_xproc(HTTP_POINT_ADDL_HEADER:*NULL)

Whether this is good or bad advice for this scenario, I don't know...  it would require someone who is familiar with what should/shouldn't be passed to the API to say "send X, but don't send Y" and you adjust the code to match.

-- 
Scott Klement
sk@xxxxxxxxxxxxxxxx
On 4/14/2021 12:44 PM, Les Turner wrote:

Hi All,

 

I am calling a web service that requires several steps. Each step returns a string in the header that is used in the URL for the next step.   It works the first time I run it, but fails on subsequent calls. By fail, I mean it doesn’t return a 303 return code.     If I wait a while (several hours or next day) and call again, it will work on the first call.  It runs in Postman every time.  Is there a cache I need to clear between calls?   

 

I have attached log files for both scenarios.   Logfile1 shows when it works properly.   Logfile2 shows a subsequent call.  Thank you for looking at this.

 

       // Set credentials

       http_setauth(HTTP_AUTH_BEARER: username: passwd);

 

       // Set first URL

       URL =  'https://api.adp.com/hr/v2/workers';

 

       // tell it we want async processing and get response.........

 

       callp http_xproc(HTTP_POINT_ADDL_HEADER:%PADDR(AdditionalHeaders));

 

       rc = http_req('GET': URL: *omit: response) ;   ç=========This works every time……………

       If rc = 202 ;

         response = http_header('link') ;                  

       Else ;

          http_comp(http_error());

          exsr $Exit ;

       EndIf;

 

       // now substring out the part of the response header that we want

       pos1 = %scan('<': response) ;

       pos1 += 1 ;

       pos2 = %scan('>': response) ;

       link = %subst(response: Pos1:  Pos2 - pos1) ;

 

       URL =  'https://api.adp.com' + %trim(link) ;

 

       // use the link to get the URL for the location of the asyncronous server

 

       rc = http_req('GET': URL: *omit: response)  ;   ç=========This call returns 303 the first time as expected

       If rc = 303 ;                                         In subsequent calls rc = 1 and no value in response header

         response = http_header('location') ;

       Else ;

          http_comp(http_error());

          exsr $Exit ;

       EndIf;

 

      // now use that part of the URL to make the fetch

 

       URL =  'https://api.adp.com' + %trim(response) ;

 

      // get the data to a file on IFS

 

      filename = '/docs/temp/adp0003.txt' ;

 

     rc = http_url_get( url : filename );

     if (rc <> 1);

        exsr $exit ;

     endif;

                                                                                 

 

 

Les Turner

Developer

Information Technology

T: 713-821-6414

 


-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi