API requests on fetching job's artifacts returns message 404 not found

I’m trying to list artifacts for a job. It does have artifacts - what I can see in https://gitlab.com/<namespace>/<group>/<project>/-/artifacts page:

However, I cannot neither get nor delete artifacts using API calls from the documentation:

because this request:

$ curl --request GET --header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" "https://gitlab.com/api/v4/projects/<ID>/jobs/<JID>/artifacts"

returns:

{"message":"404 Not Found"}

If I remove the /artifacts part from the "https://gitlab.com/api/v4/projects/<ID>/jobs/<JID>/artifacts" URL, it returns the job.

Any ideas?

I found the problem. The artifacts pages shows 1 file where there are actually no files. That file is the job.log one and it’s not available for the API calls. So when I tried to request artifacts for other jobs with more files it worked. Both GET and POST requests.

Also note that any artifact you want to download must be present in the paths array, too.

I almost went mad because this wouldn’t give me the metrics to download via the API, but only in the GUI:

jobx:
  artifacts:
    reports:
      metrics: metrics.txt

Only after adding it to the paths, too, I could download it via API:

jobx:
  artifacts:
    paths:
      - metrics.txt
    reports:
      metrics: metrics.txt
1 Like

Just to add - this is also mentioned in the docs although I only found it there after reading your post :grinning: