Hi all,
I have a requirement of having a dynamic request to an API, and send the request to another method according to the request's parameters.
Can a user send a request which is of :
{ "name" : "John Doe",
"age" : "24"}
and send another request of :
{ "Profession" : "dev",
"position" : "Senior"}
to the same API. The request may change from time to time or based on the user's needs
Thank you.
Hi @GVenkat ,
In OutSystems, you need to create a structure that includes all the attributes you plan to pass in the API request. Additionally, you should define the JSON name for each attribute within the structure.
Dynamic structures cannot be created at runtime, which is why dynamic API requests are not possible.
Solution: You can check the number of request parameters required by the API and create a structure with corresponding attributes. Values can then be passed using these attributes.
For example:
{
"parameters": {
"name": "John",
"age": "24",
"profession": "dev",
"position": "Senior"
}
Thanks,
Vipin Yadav
Hi @GVenkat , I really am curious if this was the solution, where you able to implement it like this?
Hi @Daniël Kuhlmann ,
I was able to make the parameters of the request non-mandatory and able make sure that I pass only the required parameter based on requirement.
And there's a catch where the user might send a parameter, out of configuration in the structure, into the parameter of the request. That's where the issue will persist.
The solution above was a part of what I was searching and not the complete solution for my problem