105
Views
2
Comments
Solved
change REST server at runtime
Question

Is it possible to dynamically change which server to connect to when using a REST API using local information? 

What I mean is: I know you can change the request using the "OnBeforeRequest" action, but that is a server action that doesn't allow for inputs, which means you can only access remote databases.

In my case, I need the user to input which server to connect to at runtime

2017-02-21 16-57-59
Ricardo Silva
Solution

I found a way. i'll leave it here in case someone needs it.

It was actually pretty simple, I added a header to the request with the actual server I wanted to connect to. Then, in the OnBeforeRequest action I cycled through the headers and changed the Response.BaseURL based on the value of that header.

UserImage.jpg
Diogo Soares

Hi, how do you add the header?

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