Freshservice's Projects API returning 401 error

Hello everybody, hope you’re doing great.

I’m trying to use the new gen projects endpoint in the Freshservice API, but I’m receiving a 401 unauthorized error, even with the right authentication parameters.

What should I do to make it work? Thanks!

1 Like

Hi @Matheus_Souza_Silva
Sorry for the inconvenience. can you please go through the the doc just to validate if the setup is right. Also, can you please confirm that the credentials used is an agent in the freshservice account.

1 Like

Hi @Akshay_Kumar

From what I validated in the docs, I’m making the API call correctly in Postman.

I’ve also verified that the agent whose API key I’m using, has permission to manage the projects, therefore, is capable of making API calls to /api/v2/pm/projects. However, I’m still receiving the 401 error…

Moreover, I’ve tried to make a GET request to the legacy project’s API (I don’t actually know if my Freshservice has the new gen project or the old one), but I received a 403 error:

I don’t know what can be done to make this request work :confused: . What should I do? Thanks!

Hi @Matheus_Souza_Silva,
You mentioned making API call in postman, what authorization method you are using?

Hi @Umar

I’m using the API key generated in Freshservice under “profile settings”. While in postman, I’m adding the authentication directly on the headers, like so:

Authorization: Basic <<api key encoded in base64>>

Hi @Matheus_Souza_Silva,

In Postman you can go to header tab and from drop down menu choose “Basic Auth” and use your API key as “username” and in password put some random chracter like “xxx” and then try to run. it will work.

I tried to call GET request via https://domain.freshservice.com/api/v2/pm/projects/
and got below response.


{
    "projects": [
        {
            "id": 1000241800,
            "name": "Test Project",
            "key": "BENID",
            "description": "",
            "status_id": 1,
            "priority_id": 2,
            "sprint_duration": 14,
            "project_type": 1,
            "start_date": "2022-05-31",
            "end_date": "2022-11-29",
            "archived": false,
            "visibility": 1,
            "manager_id": 18012651378,
            "created_at": "2022-09-26T19:53:44.000Z",
            "updated_at": "2022-09-26T19:53:47.000Z",
            "custom_fields": {}
        }
       
    ]
}
1 Like

@Umar thank you, I did what you suggested and it worked!

But I think this solution isn’t definitive, because I read that Freshworks will soon deprecate the user based authentication method for their APIs. So if I’m not mistaken, in the near future, this approach probably won’t work :confused:.

Nonetheless, thank you again @Umar for the help.

So, if you see while using Basic auth, instead of providing username and password i suggested you to put API key as username and random character for password. This is because username and password wont work innear future :slight_smile:

Thank you for acknowledging and do like if it helps!

Regards!

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.