Platform SDK

0
I try get All Branches API form https://repository.api.mendix.com/v1/repositories/$repoId/branches with Correct PAT  But I am getting Error {"errorCode":"RS401","errorMessage":"You need to authenticate to be able to execute this request."}
asked
1 answers
0

Hi Toon,

The error:


{

"errorCode":"RS401",

"errorMessage":"You need to authenticate to be able to execute this request."

}


usually means the PAT is either:

  1. Not being sent in the request header.
  2. Being sent with the wrong authentication scheme.
  3. Missing the required Repository/API permissions.
  4. Belonging to a user that does not have access to the repository.

A few things I'd verify:

Authorization header

Make sure you're sending the PAT as a Bearer token:


Authorization: Bearer <your_pat>



A common mistake is using:


Authorization: Basic <your_pat>


or passing the PAT as a query parameter.

Test with curl/Postman

Try calling:


curl -H "Authorization: Bearer <PAT>" </span>

https://repository.api.mendix.com/v1/repositories/&lt;repoId&gt;/branches


If this returns the same RS401, the issue is likely permissions or token configuration.

PAT permissions

When creating the Personal Access Token, ensure it includes the permissions required for Repository APIs. A valid PAT for Platform APIs does not automatically guarantee access to every repository endpoint.

Repository access

Verify that the Mendix account that created the PAT:

  • Is a member of the project.
  • Has access to the repository.
  • Can normally view branches from the Developer Portal.

Verify the Repository ID

Also make sure:


$repoId


is the actual repository ID and not the App ID or Project ID. I've seen those mixed up frequently.

Additional check

Try a simpler authenticated API endpoint first. If that also returns RS401, then the PAT is not being accepted at all. If other endpoints work and only /repositories/{repoId}/branches fails, then it's more likely a permission or repository access issue.

Most of the time with Repository APIs, RS401 comes down to the Authorization header not being passed as:


Authorization: Bearer <PAT>


or the PAT user lacking access to the target repository.

Hope this helps.


answered