XRAY: How to resolve {"error":"failed to get artifacts"} from Xray get artifacts REST-API

XRAY: How to resolve {"error":"failed to get artifacts"} from Xray get artifacts REST-API

AuthorFullName__c
Dor Tambour
articleNumber
000005950
FirstPublishedDate
2024-01-04T09:28:56Z
lastModifiedDate
2025-05-14

When using the REST-API Get Artifacts you will sometimes get the response: {"error":"failed to get artifacts"}.

This error is due to the nature of the commands to timeout after 30 seconds so if you got a lot of indexed repositories or builds or a lot of artifacts in the repository the REST API will timeout before finishing. 

These REST-APIs are designed to be paginated, which means that if the command is timing out you can resolve it by getting small chunks each time.

For example, I have a repository named example-repo which is populated with 10000 indexed artifacts, I am using the following REST-API command for 4000 entries:
 

curl -XGET -u<user>:<password> <JFROG_URL>/xray/api/v1/artifacts\?num_of_rows\=4000\&repo\=example-repo 

And I get {"error":"failed to get artifacts"}.

In order to make it work I’ll use small chunks (1000 entries) instead:
 
curl -XGET -u<user>:<password> <JFROG_URL>/xray/api/v1/artifacts\?num_of_rows\=1000\&repo\=example-repo > output.json

This will result in a result for the first 1000 entries and I’ll get a field that tells me the offset:
 
“offset” : 1000

We can use jq 'del(.offset)' output.json > output.json to remove the offset and concatenate the next page:
 
curl -XGET -u<user>:<password> <JFROG_URL>/xray/api/v1/artifacts\?num_of_rows\=1000\&repo\=example-repo\&offset\=1000 >> output.json

We can do it until we get “offset” : -1 and then we’ll know we got all of the artifacts results for the repository.