Search code examples
jsonrestalmhp-quality-centerhp-alm

Bulk update run steps in HP ALM using ALM API


My intention is to do bulk update of a test run steps. I have created test set folder -> test set instance-> test run. I can update a test run by posting json with url

  https://qcurl/qcbin/rest/domains/DOMAIN_NAME/projects/PROJECT_NAME/runs/run_id

{"Fields":[{"Name":"status","values":[{"value":"Passed"}]}]}

This works fine

Now according to the API

Post, Put To create or update more than one entity of the same entity type, pass the data in the request body. Pass an XML string compliant with the Entities Collection Schema or a JSON string of the same format returned by a GET operation on the collection.

To create entities, use an HTTP POST call. To update entities, use an HTTP PUT call.

Pass one of these content-type headers: content-type="application/xml;type=collection" content-type="application/json;type=collection"

Use the content-type header that matches the data you are sending

now i tried many combinations of posting the json for bulk update , everytime i get an error with

{
 "Id": "qccore.method-not-allowed",
 "Title": "Method not allowed",
 "ExceptionProperties": null,
 "StackTrace": null
}

The json i tried to post to url

http://ALM_URI/runs/<run_id>/run-steps


 {
"entities": [{
        "Fields": [
            {
                "Name": "id",
                "values": [{
                        "value": "1219"
                    }
                ]
            }, {
                "Name": "status",
                "values": [{
                        "value": "Failed"
                    }
                ]
            }
        ]
    }, {
        "Fields": [
            {
                "Name": "id",
                "values": [{
                        "value": "1220"
                    }
                ]
            }, {
                "Name": "status",
                "values": [{
                        "value": "Passed"
                    }
                ]
            }
        ]
    }

]

}

and this one as well

{
"data": [
    {
        "Fields": [
            {
                "Name": "id",
                "values": [
                    {
                        "value": "1215"
                    }
                ]
            },
            {
                "Name": "status",
                "values": [
                    {
                        "value": "N/A"
                    }
                ]
            }
        ]

    },
    {
        "Fields": [
            {
                "Name": "id",
                "values": [
                    {
                        "value": "1216"
                    }
                ]
            },
            {
                "Name": "status",
                "values": [
                    {
                        "value": "N/A"
                    }
                ]
            }
        ]

    }
  ]

}

So far none of them seems to be work. If anyone has done any bulk operations on any ALM API resources please can you point out where iam going wrong in posting request. FYI this is a PUT request . Thank you in advance


Solution

  • @Macintosh_89: the operation should be possible (singularly). What is missed in your case is the run-steps (in the url):

    POST/PUT/GET/DELETE    https://qcurl/qcbin/rest/domains/DOMAIN_NAME/projects/PROJECT_NAME/runs/run_id/run-steps
    

    If you want to GET some existing run steps then you can even give the run-steps-ID in the end of the previous line.

    The run-steps modification by REST API (POST-PUT-GET-DELETE) it should be possible for version higher than QC 11.50, so please have a look at your QC REST library.

    Coming to your question if you can send a bulk query for multiple run-steps, I am also looking for a solution, but so far I am using a for loop that is reporting all the run-steps one by one.

    So please try before to send only one run-steps dict and afterwards send the next steps to the QC. In case you will be able to send to the QC a multiple request in one shoot, than please let me know.

    Otherwise the method suggested above is working stable in my case and it is not such a huge time consuming.

    Hope this clarify your query! Ciao and have a nice day.

    I had a look and for the HP ALM 12.53 it is possible to update multiple instances at once. Have a look at the below link:

    http://alm-help.saas.hpe.com/en/12.53/api_refs/REST/Update_Multiple_Instances.htm

    In previous version like 11.52 that I am using, it is still possible to send bulk operations on multiple entities, but remember to add in the headers the content type as you mentioned.

    Post, Put To create or update more than one entity of the same entity type, pass the data in the request body. Pass an XML string compliant with the Entities Collection Schema or a JSON string of the same format returned by a GET operation on the collection.

    To create entities, use an HTTP POST call. To update entities, use an HTTP PUT call.

    Pass one of these content-type headers: content-type="application/xml;type=collection" content-type="application/json?type=collection"

    Use the content-type header that matches the data you are sending.

    Last but not least for the run-steps I guess this operation is not permitted. Since the run-steps are maybe considered as subentities of one entity. If I found a bulk way for the 11.52 then I will let you know ;)

    Have a nice day and hope I helped you a bit! Ciao