Not able to use addTestStep to XRAY Test

David Tsairi
Contributor
July 29, 2024

 

Got following message :


b'{"errors":[{"message":"Cannot query field \\"addTestStep\\" on type \\"Query\\". Did you mean \\"getTestSet\\" or \\"getTestSets\\"?","locations":[{"line":3,"column":9}]}]}'

I had follow the instructions in :

https://us.xray.cloud.getxray.app/doc/graphql/addteststep.doc.html


 

mutation = f"""
    {{
        addTestStep(
            issueId: "{issue_id}",
            versionId: {version_id},
            step: {{
            action: "Use Tsairi Xray Cloud Rest Api to add a new Step to the Test",          
            result: "Step was added to the Test"                  
            }}
        ) {{
            id        
            action
            data
            result
            }}
    }}
    """

    data = {
        "query": mutation
    }

   

    response = requests.post(url, headers=headers, json=data)

3 answers

3 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
David Tsairi
Contributor
July 30, 2024

Thanks Stefan !! I will give it a try

David Tsairi
Contributor
July 30, 2024

Hi Stefan , thanks a lot for your help !!! Its working for me now ,

it was a matter of format and use of double Parenthesis,

Here is my working python code look like:



    # Headers
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {auth_token}"
    }  


    data = {"query": "mutation{ addTestStep(issueId: \""+issue_id+"\",step:{action: \"this is the action\",result: \"this should be the result\"}){id action data result}}"}

   

    response = requests.post(url, headers=headers, json=data)
Like Stefan Salzl likes this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 30, 2024

Awesome. So good to hesr it‘s working 💪🏼

0 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 30, 2024

Hi @David Tsairi 

unfortunately I´m not familiar with python or how those calls could be invoked via python. 

I tried to call via webRequest action in a jira automation rule and the following call worked fine:

{"query": "mutation{ addTestStep(issueId: \"11188\",step:{action: \"this is the action\",result: \"this should be the result\"}){id action data result}}"}

 

Therefore the ednpoint itself is working.

 

Why is it that there is a double

{{ 

and

}} 

in your script? Can´t this notation in any docu (neither in the github docu which documents those python to graphql stuff).

Could you try to change those to single { } ?

 

Best
Stefan

0 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 29, 2024

Hi @David Tsairi - welcome to the community,

how/where is the api called/ the call invoked?

I dunno that type of notation. what stands the ‚f’ in front of the mutation string stands for?

Did you try to invoke the call via postman or curl?

Best
Stefan

David Tsairi
Contributor
July 29, 2024

Dear Stefan , thank you for replying!

The f' enable me to insert external parameters as issue_id or versioId in python .

I have tried other entities which works as "

getExpandedTest  in same way .

But it doesn't recognize addTestStep , it implicitly mentions in the help guide.
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events