Login Beanstalk API

Asked

Viewed 74 times

2

I’m trying to make an integration with the service of http://api.beanstalkapp.com/ and I’m having trouble making the request in C#, always returns me 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: Unexpected error in an upload.

Follow the code:

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();
  • What address are you trying to request?

  • https://{Domain}.beanstalkapp.com/api/users/Current.json

1 answer

1


I created an account at Beanstalk just so I could test this.

There are two things wrong with your code:

  1. The requisition nay should be made about 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

  2. That’s not quite clear, but it looks like you’re sending usuario:senha in the header Authorization. It is right to send usuario:token. The token must be generated in https://domain.beanstalkapp.com/access_tokens

  • Thank you! really worked with http, already the question of the password or Token works both.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.