Hello Outsystems Community,
I am looking to integrate data from an external site using APIs as a means to use as a 'pseudo-database' for an app of mine. I am still new to the world of APIs but I'm learning nevertheless.
I currently have two calls to a consume REST API, one being a POST request to get the token for the subsequent API calls and a GET request to get all the users of the integration, and eventually populate a pre-defined entity or table with users of a specific username.
My question is: I have the POST request's response stored in a session variable named 'APIToken'. Currently, my GET request can be accessed through the Request header: "Authorization" and response header with "Bearer{APIToken}". Though currently I have to type the token in manually in order for it to work. How do I pass the session variable I created through the POST requests into the Reponse Header for the GET request?
Hi,
You can use the OnBeforeRequest method where you can manipulate the data and headers of the REST request as per your requirement.
https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Consume_REST_APIs/Simple_Customizations
https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Consume_REST_APIs/Advanced_Customizations
Here's the ref Solution Answer:
https://www.outsystems.com/forums/discussion/40945/consume-rest-api-and-send-custom-headers-in-onbeforerequest/#Post147822
Cheers
Cody Zehner wrote:
Can you share the request Structure for the Same?
assif_tiger wrote:
For the POST call? Request: Content-Type, Response: application_xwwwformurlencoded.
The URL I am calling looks like this: {host}/api/public/v1/oauth2/token?grant_type=client_credentials. Let me know if that answers your inquiry.
Thank you for your reply, assif_tiger. I think this will work for what I need!