I'm using the System.Net.Http PCL library on iOs/Android with Xamarin. The distinction is necessary as this code works just fine with the non PCL version. I'm simply trying to add content to the body of an HttpRequest, but an exception is thrown. The exception is only thrown (for my case) when the name contains [] (brackets), though it probably fails on other extended characters.
The exception I get is:
Invalid format. at System.Net.Http.Headers.NameValueHeaderValue.set_Value (System.String value)
I think it's pretty straightforward in that it's choking on the bracket as when I remove the bracket, it works just fine. I tried encoding it (e.g. mynamedvalue%5Bfoo%5Da) but unfortunately, that was not the trick (though it did post successfully, it came through the with encoding in the name. I also tried string literals, and a string literal with escape [ but these yielded the same exception.
I suspect this is probably just a parsing error in the PCL, however, if it is not and someone has an idea where I might be going wrong, I'd sure appreciate it.
Or, if anyone knows of a good workaround, that would be fantastic as well.
I thought I had a workaround setting the MultiFormData part myself via serialization, but what kind of object would I use? I tried many dictionary's of strings, objects and httpcontents which successfully posts but the name isn't there (e.g. Dictionary<string,HttpContent> data = new Dictionary<string,HttpContent >();