Getting raw files from repo using API returns "404 Project Not Found" on an internal project using a project access token

Summary

Im running a script on the pipeline to get raw content of a json file from the main branch of the same project. I'm using the API from docs mentioned here. I've created a Project Access Token & added the required perms (api, read_api, read_repository). Gitlab version is 15.5.x

The script I'm running is (exactly as mentioned in the docs):

curl --header "PRIVATE-TOKEN: <MY_TOKEN>" "https://gitlab.com/api/v4/projects/xxx/repository/files/package%2Ejson?ref=main"

This is the response in the pipeline:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    35  100    35    0     0     92      0 --:--:-- --:--:-- --:--:--    92
{"message":"404 Project Not Found"}

The project obviously exists (screenshot below):

Screenshot_2023-01-18_at_16.29.52

If I make the call via the browser, Im getting the json raw content back - https://gitlab.com/api/v4/projects/xxx/repository/files/package.json/raw?ref=main

Steps to reproduce

  1. Create a internal repo and initiate a pipeline
  2. Create a Project Access Token and give it "Maintainer" access with perms "api, read_api, read_repository"
  3. Create a job in the .gitlab-ci.yml and add the above mentioned curl script
  4. Push the code and observe the pipeline

What is the current bug behavior?

In the pipeline, I get the following response:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    35  100    35    0     0     92      0 --:--:-- --:--:-- --:--:--    92
{"message":"404 Project Not Found"}

What is the expected correct behavior?

Expecting the script mentioned in the GL docs to return the raw content of the JSON file

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Gitlab 15.5.x Running with gitlab-runner 15.5.1

Edited by James Heimbuck