When making a POST call using a WebClient, how do I send duplicate values in the NameValueCollection?

空扰寡人 提交于 2019-12-08 07:57:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!