Handling parameters in UiPath POST API call (Passing a single argument with multiple values)

Hi All,
I need to call a third part POST API Call with fill in Header and Request Body parameters. Its OAuth2.0 and i am able to pass the JWT-Token in the request. Everything works fine.

But I have to pass one parameter in the same request body with different values. i was able to do the same with PostMan and its working fine. But i am unable to do the same step with UiPath.

Parameters collection is not allowing to add/repeat same argument with different values like PostMan. So i am stuck here how to frame multiple variable values to one argument and pass it. Please help me.

PostMan Body parameters which is working fine:

@KrishnaKishore

Instead of giving body like this..try to use body as string and pass it to check if that works

Hope this helps

Cheers

Hi @Anil_G Could you please share the image or text i need to pass as Body ? I am unable to see your image.

@KrishnaKishore

Its the json text that you need to pass

eg:


{
"Key":value,
"Key1":value1
}

cheers

@Anil_G Thanks. But if i want to add multiple values for the same key ?

Ex:

{
“Key”: value,
“Key1” : Value1,
"Key1:: Value2
}

Does this allowed ?

@KrishnaKishore

Thats an example of structure alone ..not key or value so you can

If you try would be good

cheers

You can try formatting the repeated parameter values as a JSON array in the request body if the API supports it—something like "custom_behavior": ["value1", "value2"]. UiPath doesn’t support repeating the same key in the dictionary, so using a properly structured JSON string might help. Also, make sure to set the content type to application/json if you’re switching from form-data.

1 Like

@nullsbrawlone Hi - It didnt work. Its not able to understand it.

@KrishnaKishore

How about if instead of strings there, you use the type as array of strings and then provide multiple values?

Can you try and see if this works?

@sonaliaggarwal47 i tried this option. No Luck.. still getting failure.

Hi @KrishnaKishore

Can you please show how you tried the way suggested by @nullsbrawlone

That should work.

Are you passing it under request body? And setting content type as application/json instead of application/form data?

Can you please share screenshots of the request you are passing under body of your http request activity?

Sharing sample format below:

{
“Key”: “value”,
“Custom-behavior”: [“text 1”, “text2”, “text 3”],
“Key 1”: “value 1”
}

@sonaliaggarwal47 Unfortunate target API system is not allowed to pass the request body in Json format. They are accepting only form-data. Even i pass the key value pairs in request body parameter as a string, i am not getting success response. So i have left with only option to use the parameter wizard and pass multiple values under a same variable.

@KrishnaKishore

Try concatenation the multiple values by comma..

Something like below:

“Text1,text2,text3”

Or try
“Text1+text2+text3”

Or may be
Textvariable1+”,”+textvariable2+”,”

Just try different syntax’s and see which one works in your case.

@sonaliaggarwal47 Sorry to say this, tried all options. Since i need to pass a URL in the parameter, whatever concentration i tried, the target system considers its part of the URL and expected behavior is changing.

Hi @KrishnaKishore,
Please take a stab at this:

var options = new RestClientOptions("")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("https://postman-echo.com/post", Method.Post);
request.AddHeader("Cookie", "sails.sid=%2Fx0eIeXFeenPlxFDQwVok");
request.AlwaysMultipartFormData = true;
request.AddParameter("foo1", "bar1");
request.AddParameter("foo1", "bar2");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

@sudster Sure, Let me give a try. Would you please tell which parameter i need to pass JWT token. Since this is OAUTH2.0 POST API Call.

@KrishnaKishore , you mentioned you’ve successfully tested your request using Postman. Then follow these steps: