0

我还有其他可以正常工作的表单帖子,但由于某种原因,这个帖子会引发“System.ArgumentException:值不在预期范围内”。信息。

有什么问题?

using (HttpClient client = new HttpClient())
{
    HttpMultipartFormDataContent data = new HttpMultipartFormDataContent();
    data.Add(new HttpStringContent(about ?? String.Empty), "about");
    data.Add(new HttpStringContent(displayName ?? String.Empty), "name");
    data.Add(new HttpStringContent(email ?? String.Empty), "email");
    data.Add(new HttpStringContent(firstName ?? String.Empty), "firstName");
    data.Add(new HttpStringContent(lastName ?? String.Empty), "lastName");
    data.Add(new HttpStringContent(phone ?? String.Empty), "phone");
    data.Add(new HttpStringContent(isPublic.ToString()), "isPublic");
    data.Add(new HttpStringContent("true"), "isPrimaryProfile");

    Uri uri = new Uri(url, UriKind.Absolute);
    HttpResponseMessage responseMessage = await client.PostAsync(uri, data);

}
4

1 回答 1

2

啊,显然空字符串不是 HttpStringContent 的有效值。

于 2013-09-21T00:10:47.680 回答