Login Beanstalk API

2

I'm trying to do an integration with the http://api.beanstalkapp.com/ service and I'm having trouble doing the request in C #, it always returns the error below:

  

An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code

     

Additional information: The underlying connection was closed: An unexpected error occurred while sending.

Follow the code below:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlBeanstalk);
request.Method = "GET";
request.Accept = "application/json";
request.ContentType = "application/json; charset=utf-8";
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password)));
WebResponse response = (HttpWebResponse)request.GetResponse();
    
asked by anonymous 06.07.2016 / 21:08

1 answer

1

I created an account at Beanstalk just to be able to test it.

There are two things wrong with your code:

  • The no request should be made over HTTPS (I know the example in the manual itself shows this, apparently it is wrong)

    Change the address to http://{domain}.beanstalkapp.com/api/users/current.json

  • This is not clear, but it looks like you are sending usuario:senha in header Authorization . The right thing is to send usuario:token . The token must be generated at link

  • 07.07.2016 / 20:59