问题
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?
回答1:
I was actually able to use the UploadString() method on the webclient and build the POST data string manually using HttpUtility.UrlEncode.
来源:https://stackoverflow.com/questions/18541944/when-making-a-post-call-using-a-webclient-how-do-i-send-duplicate-values-in-the