circuit-sdk

how to pass multiple type of data to API from server side as formdata?


I want to create circuit (messenger like skype) conversation from my server side code (C#) by calling circuit api.

Function : https://circuitsandbox.net/rest/v2/conversations/

I have to pass two type of parameters :

1) Participants - string array

2) topic - string

According to function definition (in swagger), I have to pass them as formdata. But, when I am trying to encode the parameters

var content = new FormUrlEncodedContent(values);

It is not accepting the array string for participants list. It is expecting "key/value" pair as "string/string".

I have even tried to create the JSON serialization also

JsonConvert.SerializeObject(values)

But the API definition is not accepting this converted values as it is expecting formdata in string/string as key/value.

I had even tried to concatenate the participants list with ";" as delimiter. But in that case, I am getting 400 error.

I tried to convert my parameters like this also

var formData = new List>();

formData.Add(new KeyValuePair("participants", JsonConvert.SerializeObject( participants)));

formData.Add(new KeyValuePair("topic", "Testing1"));

But again, I a getting 400 error.

Here is my API call

var response = client.PostAsync("https://circuitsandbox.net/rest/v2/conversations/group", content);

Can someone provide me some code snippet to pass that this data to API?

Let me emphasis, I am trying from server side code (C#) and not jquery code.


Solution

  • as we checked together earlier today, make the participants value a comma separated string of emails and it should work