Page 1 of 1

httpapi documentation

Posted: Thu Dec 16, 2021 1:45 am
by Theju112
pls let me know if there is any docs for httpapi ?

for eg, doc which describes parameters to pass to http_xproc?

I am struggling to understand below code. the http_strig is taking only the form_data as input..so how exactly is the form header used? Apologies my web knowledge is very limited.

Code: Select all

form_header = 'Authorization: Basic ' + %trim(WSBASE64) + CRLF;
http_xproc( HTTP_POINT_ADDL_HEADER : %paddr(setHeader));       
url = WSAUTURL;                                                
                                                               
//-------------------------------------------------------------
// Step 1 - Get ID Token                                       
//-------------------------------------------------------------
                                                               
  form_data =  'grant_type=client_credentials'                 
       //+ '&' + 'client_id=' + %Trim(WSCSKEY)                 
       //+ '&' + 'client_secret=' + %Trim(WSCSSEC)             
       + '&' + 'scope=openid';                                 
enJL = %len(%trim(form_data));                                 
                                                               
                                                               
clear retdata;                                                 
Monitor;                                                       
   retdata = http_string('POST': url : %trim(form_data) :      
                         'application/x-www-form-urlencoded'); 

Re: httpapi documentation

Posted: Thu Dec 16, 2021 2:00 am
by Scott Klement
The "documentation" is in comments in the HTTPAPI_H member, as well as the examples named EXAMPLExx.

Re: httpapi documentation

Posted: Thu Dec 16, 2021 11:52 am
by Theju112
Hi Scott,

Also kindly help with the code snippet I have added to my original question.

Re: httpapi documentation

Posted: Fri Dec 17, 2021 1:57 am
by Scott Klement
I don't understand why it is called "form_header" -- it appears to be an HTTP header (rather than a form header), specifically, it is someone's manual implementation of HTTP Basic Authentication. I don't understand why someone would code that, though... HTTPAPI has built-in support for basic authentication... why write it yourself?

Presumably, "form_header" is a global variable that is being utilitized by the SetHeader() subprocedure. It's hard to tell, however, since you haven't posted the code for the SetHeader() subprocedure, or the definition of "form_header", I don't know that for certain.

Perhaps you can ask whomever wrote it why they wrote it that way?