0

I know that if you want to POST a variable to Web API with WebClient you do not include the parameter key

using (WebClient client = new WebClient())
{
    string URI = "http://blablabla/api/testaction";
    string myParameters = "=TEST";

    using (WebClient wc = new WebClient())
    {
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

        string HtmlResult = wc.UploadString(URI, myParameters);
    }
}

My question is why can't you include the parameter key?

string myParameters = "myParam=TEST"; // doesn't work

What do you do if you want to pass more than one parameter?

4

1 回答 1

0

你应该写像

http://blablabla/api/testaction?parmeterName=parameterValue?pName=pValue

所以基本上我会这样写

string URI = "http://blablabla/api/testaction";
string myParameters = "?param=TEST";
于 2015-02-10T15:38:11.497 回答