I wish to send multiple values to the Google Translate API using the simple syntax provided by the C# WebClient
. To send multiple values to the API, each value has to have the same query-string key, for example: q=value1&q=value2
.
I cannot use the default GET mechanism and simply put these values on the query-string because some of my values are too large. I therefore have to POST these values making sure I set the X-HTTP-Method-Override
header.
The problem is, to POST my values I need to use the WebClient.UploadValues()
method which expects the values to be presented as a NameValueCollection
. Multiple values with the same key are supported by the NameValueCollection
but not in a way that the Google Translate API will recognise as separate values (it creates a simple comma delimited set of values held under a single key unique key).
How do I POST multiple values, each with the same key, using the WebClient
class?
For further reading see: