Home > Blockchain >  Jfrog X-RAY API not working for "Get Reports List"
Jfrog X-RAY API not working for "Get Reports List"

Time:07-22

Following reference Xray REST API - GetReportList

Below example returns - {"error":"Failed to parse request pagination params"}

##  Get Reports List
curl -s --request POST \
  --user 'svc_api_xray':$(cat ~/secrets/.svc_api_xray | base64 --decode) \
  --data '{
  "filters": {
    "name": "shared-installers",
    "status": [
      "completed"
    ],
    "report_type": [
      "vulnerability"
    ],
    "author": "svc_api_xray ",
    "start_time_range": {
      "start": "2022-07-13T12:22:16Z",
      "end": "2022-07-13T12:22:16Z"
    },
    "end_time_range": {
      "start": "2022-07-13T12:22:16Z",
      "end": "2022-07-13T12:22:16Z"
    }
  }
}' \
  ${ARTIFACTORY_URL}/xray/api/v1/reports

Have tried removing elements until all I have is report_type and still get the same error. Is there something missing from this documentation?

If I use the pagination parameters in the example I get the following error

[1] 19905
[2] 19906
[3] 19907
[2]-  Done                    page_num=1
[3]   Done                    num_of_rows=10
{"error":"Failed to parse request pagination params"}

CodePudding user response:

It's a documentation bug. The parameters are mandatory to pass.

curl -u admin -p password -X POST "http://myartifactory:8082/xray/api/v1/reports?direction=asc&page_num=1&num_of_rows=10&order_by=name"

This should work fine.

CodePudding user response:

So although Gajapathi was partly correct, the pagination parameters were not optional, the issue here was the lack of quotes around the Artifactory URL. Guess this may be a requirement of pagination?

The final solution, with a slightly different filter:

curl --location --silent --request POST \
  --user ${USER}:${API_TOKEN} \
  --data '{
  "filters": {
    "status": [
      "completed"
    ],
    "report_type": [
      "vulnerability"
    ]
  }
}' \
  "${ARTIFACTORY_URL}/xray/api/v1/reports?direction=asc&page_num=1&num_of_rows=10" | jq -r
  • Related