0

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.

Christophe Debove
  • 6,088
  • 20
  • 73
  • 124
  • the error is Bad Username or password for non Fench reader. – Christophe Debove Dec 06 '11 at 14:52
  • 1
    When you say you tested it in the browser .. was this tested on your local machine vs a machine on your network / domain. perhaps the from what I can see you are only using the password.. unless cmdLogon is the user name.. but that looks to be more like a method() to call – MethodMan Dec 06 '11 at 15:00
  • @DJ KRAZE I don't understand what you said "you are only using the password.." – Christophe Debove Dec 06 '11 at 15:04

1 Answers1

1

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.

Community
  • 1
  • 1
Jeff Ogata
  • 56,645
  • 19
  • 114
  • 127