Example of a CURL request to create a Test Execution

  • curl -X POST --url "https://xray.cloud.getxray.app/api/v2/graphql" -H "Authorization: Bearer token" -H "Content-Type: application/json" --data "{ \"query\":\"mutation{ createTestExecution(testIssueIds:[\\\"33920\\\"] jira:{fields:{summary:\\\"Test Execution for AMGT\\\",project:{key:\\\"AMGT\\\"}}}){testExecution {issueId jira(fields: [\\\"key\\\"])}warnings createdTestEnvironments}}\"}"



Example of a CURL request to get a Test Run ID

  • curl -X GET --url "https://xray.cloud.getxray.app/api/v2/graphql" -H "Authorization: Bearer token" -H "Content-Type: application/json" --data "{ \"query\":\"{ getTestRun(testIssueId: \\\"33920\\\", testExecIssueId: \\\"33922\\\" ){id}}\"}"



Example of a script using GraphQL to add Steps to a Test

BASE_URL=https://xray.cloud.getxray.app/api/v2
#TEST_KEY=CALC-129§
QUERY="{ \"query\": \" mutation { addTestStep(issueId: \\\"11235\\\", step: { action: \\\"do this\\\", result: \\\"expected res\\\" } ) {  id, action, data, result } }   \"  } "
xpto=<<END
mutation {
    addTestStep(
        issueId: "11235",
        step: {
            action: "Use Xray Cloud REST API to add a new Step to the Test",
            result: "Step was added to the Test",
        }
    ) {
        id
        action
        data
        result
    }
}
END
echo $QUERY
token=$(curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" "$BASE_URL/authenticate"| tr -d '"')
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d "$QUERY"  $BASE_URL/graphql

https://xray.cloud.getxray.app/doc/graphql/index.html