1
试图张贴到松散API,并有关于如何在我的文章中包含附件部分的问题。我有一个方法,它看起来像c#如何发布FormUrlEncodedContent时,对象不平坦
public KeyValuePair<string, string>[] GetParameters()
{
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("token", Token));
parameters.Add(new KeyValuePair<string, string>("channel", Channel));
parameters.Add(new KeyValuePair<string, string>("text", Text));
parameters.Add(new KeyValuePair<string, string>("as_user", As_User.ToString()));
return parameters.ToArray();
}
但我的对象有一个数组,我需要包括附件,看起来像
public class Attachment
{
public string text{get; set;}
public string pretext{ get; set;}
}
试图找出如何将在keyvaluepair附件我在这里返回的数组。或者,这可能不是正确的方法来做到这一点?
为了什么它的价值,这是我如何创建后
using (HttpClient client = new HttpClient())
{
var parameters = response.GetParameters();
var requestContent = new FormUrlEncodedContent(parameters);
HttpResponseMessage r = await client.PostAsync(baseurl, requestContent);
HttpContent responseContent = r.Content;
}
是的谈论chat.postMessage。 –