pflegosv

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Thanks @Nathan, thanks @Dragma. Let me reply in order. @Nathan: I discovered that same RestSharp code behaves in different ways In Visual Studio 2017 and in MonoDevelop, because the code I submitted yesterday works fine in VS (returning the user token finally, "GOT IT !!!"), while in MonoDevelop it returns the error I submitted... Sorry for misleading information, but during the day I cannot use VS, so I made a test on Ubuntu with MonoDevelop, thinking it was the same... @Dragma: I am quite new in RestAPI and C#, but it seems to me that you are not using RestSharp in your code, but the System.Net.Http namespace objects. Anyway thanks for your support, I have seen your method to encode the username an password parameters and it should be similar to one I used. Best regards and happy coding !!!
  2. Thanks for your quick reply. May you explain what do you mean? I have tried following code, without success: var client = new RestClient(); client.BaseUrl = new Uri("https://rebrickable.com/api/v3/); var request = new RestRequest("users/_token/", Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); //Tried also with application/json request.AddHeader("Authorization", "key <my key>"); request.AddParameter("username", "<my username>"); request.AddParameter("password", "<my password>"); IRestResponse response = client.Execute(request); In this case I receive an empty response with following ErrorMessage: "Error: SendFailure (Error writing headers)" Thank you very much for your support. Best regards.
  3. Hi everyone in Rebrickable forum. I am looking to code a VS 2017 application (at this time a simple console application just to test APIs) to manage my LEGO collection. I decided to use RestSharp library to access data via REST APIs and I'm facing a problem with POST requests. In particular I'm trying to get the user token and I receive an 'Invalid credentials' error when I try the following code: var client = new RestClient(); client.BaseUrl = new Uri("https://rebrickable.com/api/v3/); client.Authenticator = new HttpBasicAuthenticator("<my username>", "<my password>"); var request = new RestRequest("users/_token/", Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "key <my key>"); IRestResponse response = client.Execute(request); May some of you help me to solve this issue? Thanks in advance, best regards.