11
Views
8
Comments
Solved
Dynamic API query parameter build not working
Question

I am trying to build a query parameter dynamically for a GET API call to Microsoft Graph, but for some reason OutSystems doesn't seem to enable this.


The API Endpoint in OutSystems is:


https://graph.microsoft.com/v1.0/users('{UserEmail}')/mailFolders/{MaiFolderId}/messages?{SearchText}$select=id

Where {SearchText} is the parameter I am trying to build dynamically. The value being sent into the API as this input is:


"$search="subject:max* OR body:max*"&"


Which works when I manually put it like this into the Testing feature of the API, but when I send this in runtime (and I checked this is what is going in when debugging), then it does not actually send the parameter in the API call, it just sends '{SearchText}' which is super strange - so it doesn't replace that parameter with the value I put in for it like one would assume it would.

So the API call from Integration Log details is this:


Is this a limitation in OutSystems or am I doing something wrong?

Champion
Solution

Hi @Nicholas Campbell 

Try to use url like this

https://graph.microsoft.com/v1.0/users('{UserEmail}')/mailFolders/{MaiFolderId}/messages?SearchText={SearchText}$select={Id}

It will make searchtext as dynamic parameter 

Best

Arun

Hi Arun

Unfortunately this would not fit the requirment as I need to be able to exclude the SearchText field from the URL depending - due to Microsoft Graph requirements. Hence why I need the 'SearchText=' part to be within the dynamic part so that I can exclude it if need be.

Solution

Hi Nicholas,

This is not true. If you set the parameter to non-mandatory, OutSystems recognizes when there's no value, and omits the variable name as well. So just make sure "SearchText" is marked optional and what you want should happen automatically.

Hi Killian

I tested this and you are right! So this would work then as an option then Arun. Many thanks both of you.

You're most welcome! Glad you got your problem solved. Don't hesitate to mark Arun's answer and mine as "Solution" :). Happy coding!

Solution

Hi Nicholas,

This is not true. If you set the parameter to non-mandatory, OutSystems recognizes when there's no value, and omits the variable name as well. So just make sure "SearchText" is marked optional and what you want should happen automatically.

Hi,

I have a similar use case that works for me. I am including my input variable in the URL. You can find more information at this link: customize_rest_urls.



Hi Narendra

Thanks for answering here. I believe this is applicable for exposing APIs though and I am consuming them...

Champion
Solution

Hi @Nicholas Campbell 

Try to use url like this

https://graph.microsoft.com/v1.0/users('{UserEmail}')/mailFolders/{MaiFolderId}/messages?SearchText={SearchText}$select={Id}

It will make searchtext as dynamic parameter 

Best

Arun

Hi Arun

Unfortunately this would not fit the requirment as I need to be able to exclude the SearchText field from the URL depending - due to Microsoft Graph requirements. Hence why I need the 'SearchText=' part to be within the dynamic part so that I can exclude it if need be.

Solution

Hi Nicholas,

This is not true. If you set the parameter to non-mandatory, OutSystems recognizes when there's no value, and omits the variable name as well. So just make sure "SearchText" is marked optional and what you want should happen automatically.

Hi Killian

I tested this and you are right! So this would work then as an option then Arun. Many thanks both of you.

You're most welcome! Glad you got your problem solved. Don't hesitate to mark Arun's answer and mine as "Solution" :). Happy coding!

Champion

I'm glad that I helped to solve problem

Thanks

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