Open link in a new tab

Content

Expand project menu

Authentication Error in API V3

I am facing a persistent problem trying to authenticate to api through a C # application.

I am using RestClient.Authenticator = new HttpBasicAuthenticator (username, password) to authenticate the user and access the services, but always give me the following message:

{"_type":"Error","errorIdentifier":"urn:openproject-org:api:v3:errors:Unauthenticated","message":"Você não forneceu as credenciais corretas."}

*VISUAL STUDIO*

This is C# code:

public void OpenCall()
{
    SetParameters();

    _restRequest.Parameters.Clear();

    _restClient.BaseUrl = new Uri(StringUri);
    _restRequest.AddHeader("Content-type", "application/json");
    _restClient.Authenticator = new HttpBasicAuthenticator(Auth[0].Trim().ToLower(), Auth[1].Trim().ToLower());
    _restRequest.Resource = "/api/v3";
    _restRequest.RequestFormat = DataFormat.Json;

    var result = _restClient.Get<object>(_restRequest);
}

In the browser my credentials work normally. I have also tried token access, and it doesn't work.

In Postman the message you receive is this:

*TESTE POSTMAN*

*The server couldn't send a response:* Ensure that the backend is working properly

*Self-signed SSL certificates are being blocked:* Fix this by turning off 'SSL certificate verification' in Settings > General

*Proxy configured incorrectly:* Ensure that proxy is configured correctly in Settings > Proxy

*Request timeout:* Change request timeout in Settings > General