Hello,
but how can I use StringContent together with my below KeyValuePair?
If you want to use new KeyValuePair<string, string>
format. You need to install Newtonsoft.Json nuget package and serialize List<Phones>
and List<Emails>
to JSON string like following code.
string PhoneBodyContent= JsonConvert.SerializeObject(all_phones);
string EmailsBodyContent = JsonConvert.SerializeObject(all_emails);
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("source_uuid", "source_uuid"),
new KeyValuePair<string, string>("emails", PhoneBodyContent),
new KeyValuePair<string, string>("emails", EmailsBodyContent),
});
If sever side receive this string. you need to deserialize Json to List<Phones>
and List<Emails>
like following code.
List<ContactPhone> d = JsonConvert.DeserializeObject<List<Phones>>(PhoneBodyContent);
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.