1

I am unfortunately at the mercy of an API that forces the reuse of parameter names in a POST call.

The end result POST params look like this:

ArgNameA: xyz
ArgNameB: abc
ArgNameC: 123
ArgNameD: LMN
ArgNameC: 789
ArgNameD: JKL
ArgNameC: ...
ArgNameD: ...

You get the idea.

I'm currently using a NamedValueCollection and sending that to a WebClient to do the POST call. That works fine but when I try to reuse ArgNameC and ArgNameD over and over, it appears to recognize the names as already existing in the collection and therefor won't add them (or maybe it updates them, I'm not sure).

How do I make a POST using a WebClient which allows me to reuse POST argument names?

jermny
  • 870
  • 2
  • 12
  • 23
  • Can you explain what you mean by "when I try to reuse"...? How are you reusing the names and in what context/area? – siva.k Aug 30 '13 at 22:08
  • I need to do a POST using a WebClient. The UploadValues used a NameValueCollection object. The NameValueCollection object won't accept two NameValuePairs if they share the same name. I want to be able to send a POST using the WebClient with multiple NameValuePairs that share the same name. – jermny Aug 30 '13 at 23:27

1 Answers1

1

I was actually able to use the UploadString() method on the webclient and build the POST data string manually using HttpUtility.UrlEncode.

jermny
  • 870
  • 2
  • 12
  • 23