Use input parameter in OnBeforeRequest of API
Question
Application Type
Reactive

Hello all,

My final goal is to dynamically change the base URL of an API.

I am doing it using the OnBeforeRequest. 

In my screen, I have a local variable called Plant which I need to use on my OnBeforeRequest.

I have an aggregate with 2 columns: one is the PlantName and the other is the API URL.

I need to go through the aggregate, and find what is the API URL for my Plant.

After that, my assign in the OnBeforeRequest will look something like this:

CustomizedRequest.BaseURL = "http://" + PlantAPIURL  + ...

However, I can't find a way to use my local variable Plant as an input parameter of my OnBeforeRequest.

Do you have a workaround to do this?

Thank you šŸ˜Š

HI Catarina,

Add a Input Parameter to the Consume API method and set the Send In as Header. Now the value will be there in header of the Rest Request. 



In OnbeforeRequest event you will get the Request object. In that get the value from the header and change the URL 

Check the below thread that is useful for your scenario.

https://www.outsystems.com/forums/discussion/41909/how-to-use-localentity-data-value-in-onbeforerequest-in-rest-api/

Best Regards

Devendra



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.