문제

I try to get the token from my fogbugz website, folowing :

http://fogbugz.stackexchange.com/fogbugz-xml-api

I have :

using (var wb = new WebClient())
{   
                var data = new NameValueCollection();
                data["cmd"] = HttpUtility.UrlEncode(cmdLogon);
                data["email"] = HttpUtility.UrlEncode(email);
                data["password"] = HttpUtility.UrlEncode(password);
                content = encoding.GetString(wb.UploadValues(url, "POST", data));
 }

Below the Server Response :

<?xml version="1.0" encoding="UTF-8"?><response><error code="1">Nom d'utilisateur ou mot de passe incorrect</error></response>

I can see the request in IIS logs but parameters are absent.

What I'm doing wrong?

edit : I'm sure parameters are correct cause I tested In the browser and it work well.

도움이 되었습니까?

해결책

I ran this with Fiddler, and your code sends a request with the following content in the request body:

cmd=logon&email=test-email&password=test-password

Instead, I believe you should be sending this information in the query string as per the documentation (see the "Logging On" section):

http://www.example.com/api.asp?cmd=logon&email=xxx@example.com&password=BigMac

If you want to use a NameValueCollection to build your querystring, this answer provides a way to do that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top