Help with passing client_id & client_secrete in POST for access token
Posted: Thu Dec 29, 2022 9:35 pm
Hi,
Can you please help me in fetching the access token while posting the below cURL request through RPG. Im getting response in postman, but missing something while coding in RPG. Attached the postman snippet. Below is the curl
----------------------------------------------------------------------------------------------------------------------------
curl --location --request POST '<URL>' \
--form 'grant_type=client_credentials' \
--form 'client_id=<Client_Id>' \
--form 'client_secret=<Client_Secret>'
----------------------------------------------------------------------------------------------------------------------------
Below is the RPG code snipped trying to invoke http_req()
form_data = 'grant_type=client_credentials'
+ '&' + 'client_id=' + '<Clinet_Id>'
+ '&' + 'client_secret=' + '<Client_Secret>';
@url = '<URL>';
Sav_Rc = http_Req('POST'
:@url
:*omit
:Output
:*omit
:%trim(form_data)
:'application/x-www-form-urlencoded');
Tried replacing content-type above with multipart/form-data,but, no response.
Can you please help me in fetching the access token while posting the below cURL request through RPG. Im getting response in postman, but missing something while coding in RPG. Attached the postman snippet. Below is the curl
----------------------------------------------------------------------------------------------------------------------------
curl --location --request POST '<URL>' \
--form 'grant_type=client_credentials' \
--form 'client_id=<Client_Id>' \
--form 'client_secret=<Client_Secret>'
----------------------------------------------------------------------------------------------------------------------------
Below is the RPG code snipped trying to invoke http_req()
form_data = 'grant_type=client_credentials'
+ '&' + 'client_id=' + '<Clinet_Id>'
+ '&' + 'client_secret=' + '<Client_Secret>';
@url = '<URL>';
Sav_Rc = http_Req('POST'
:@url
:*omit
:Output
:*omit
:%trim(form_data)
:'application/x-www-form-urlencoded');
Tried replacing content-type above with multipart/form-data,but, no response.