locked
HttpClient.PostAsync - Need help understanding why it would throw an ArgumentException RRS feed

  • Question

  • I have other form posts that work fine, but for some reason, this one for throws a "System.ArgumentException: Value does not fall within the expected range." message.

    What could be wrong?

    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);
    
    }



    Saturday, September 21, 2013 12:03 AM

Answers

  • Figured it out. An empty string is not valid.
    • Marked as answer by Steven.A.S Saturday, September 21, 2013 12:44 AM
    Saturday, September 21, 2013 12:44 AM