Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Hanuman_U Absent Member.
Absent Member.
6366 views

How to create New Run using REST API ?

Jump to solution

 

    Following are the input for POST request

 


http:// IP:Port/qcbin/rest/domains/DEFAULT/projects/TEST/runs
"Content-Type", "application/xml"
"Accept", "application/xml"

  I was able to create  Test using the same code, and then I just tweeked the entity type to 'runs' and the xml tags to   match the run fields.

 

I tried with the below tags,  to POST the run to ALM

 


<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Entity Type="run"> <Fields> <Field Name="name"> <Value>Run_REST_TEST</Value> </Field> <Field Name="test-instance"> <Value>1</Value> </Field> <Field Name="test-id"> <Value>1</Value> </Field> <Field Name="cycle-id"> <Value>1</Value> </Field> <Field Name="status"> <Value>Not Completed</Value> </Field> <Field Name="owner"> <Value>user1</Value> </Field> </Fields> <RelatedEntities/> </Entity>

 

 

But I am getting

java.io.IOException: Server returned HTTP response code: 500.

 

Did any one created run using REST ?. If so please let me know the proecedure.

    


Regards,
Hanumanth
0 Likes
1 Solution

Accepted Solutions
Highlighted
Hanuman_U Absent Member.
Absent Member.

Re: How to create New Run using REST API ?

Jump to solution

Got it.

Need more fields that are mandatory.

 

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<Entity Type='run'>
<Fields>
<Field Name='name'><Value>Run_2014-11-26</Value></Field>
<Field Name='test-instance'><Value>1</Value></Field>
<Field Name='testcycl-id'><Value>6</Value></Field> 
<Field Name='cycle-id'><Value>101</Value></Field>
<Field Name='test-id'><Value>12</Value></Field>
<Field Name='subtype-id'><Value>hp.qc.run.MANUAL</Value></Field>
<Field Name='status'><Value>Passed</Value></Field>
<Field Name='owner'><Value>user1</Value></Field> 
</Fields>
<RelatedEntities/>
</Entity>

 


Regards,
Hanumanth
14 Replies
Highlighted
Hanuman_U Absent Member.
Absent Member.

Re: How to create New Run using REST API ?

Jump to solution

Got it.

Need more fields that are mandatory.

 

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<Entity Type='run'>
<Fields>
<Field Name='name'><Value>Run_2014-11-26</Value></Field>
<Field Name='test-instance'><Value>1</Value></Field>
<Field Name='testcycl-id'><Value>6</Value></Field> 
<Field Name='cycle-id'><Value>101</Value></Field>
<Field Name='test-id'><Value>12</Value></Field>
<Field Name='subtype-id'><Value>hp.qc.run.MANUAL</Value></Field>
<Field Name='status'><Value>Passed</Value></Field>
<Field Name='owner'><Value>user1</Value></Field> 
</Fields>
<RelatedEntities/>
</Entity>

 


Regards,
Hanumanth
Absent Member.. punkhunter Absent Member..
Absent Member..

Re: How to create New Run using REST API ?

Jump to solution

This helped get me in the right direction, but was still missing one field called 'user-01' (BTW: I am using ALM 12.01). Here is what I used:

 

<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<Entity Type=\"run\">
<Fields>
<Field Name=\"name\"><Value>Run_2015-08-19</Value>
</Field><Field Name=\"test-instance\"><Value>1</Value>
</Field><Field Name=\"testcycl-id\"><Value>24</Value>
</Field><Field Name=\"cycle-id\"><Value>9</Value>
</Field><Field Name=\"test-id\"><Value>976</Value>
</Field><Field Name=\"subtype-id\"><Value>hp.qc.run.MANUAL</Value>
</Field><Field Name=\"status\"><Value>Passed</Value>
</Field><Field Name=\"user-01\"><Value>myUser</Value>
</Field><Field Name=\"owner\"><Value>myOwner</Value>
</Field>
</Fields>
<RelatedEntities/>
</Entity>
0 Likes
Absent Member.. punkhunter Absent Member..
Absent Member..

Re: How to create New Run using REST API ?

Jump to solution

I think I just realized that the user-01 field is a custom field we created. May not be a typical required field in ALM...

0 Likes
sinthiya Absent Member.
Absent Member.

Re: How to create New Run using REST API ?

Jump to solution

how do u get testcycl-id and test-id when you are creating a run instance for first time?

0 Likes
Swap_lisa Absent Member.
Absent Member.

Re: How to create New Run using REST API ?

Jump to solution

test-id => The ID of the test within the test plan

 

testcycl-id => This represents the "test instance id". I'm not sure how to get this any other way than looking it up manually.

0 Likes
EliStern Absent Member.
Absent Member.

Re: How to create New Run using REST API ?

Jump to solution

To discover the required fields for a customized project you can query the following URL:
http://{SERVER}/qcbin/rest/domains/{DOMAIN}/projects/{PROJECT}/customization/entities/run/fields?required=true

0 Likes
vikram_u_k Absent Member.
Absent Member.

Re: How to create New Run using REST API ?

Jump to solution

Hi Hanuman,

  Many thanks for sharing the details to update the test runs.

I would like to know how to add an Attachment (image) using the url.

http://stg-alm12.xy.com/qcbin/rest/domains/TEST/projects/TEST2/customization/entities/run/fields?required=true

1) What are there many mandatory fields and should are all TRUE values needed to updated the testRun?.

 

<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<Fields>
-<Field Label="Run Name" Name="name" PhysicalName="RN_RUN_NAME">
<Size>255</Size>
<History>true</History>
<Required>true</Required>
<System>true</System>
<Type>String</Type>
<Active>true</Active>
<Editable>true</Editable>
<Filterable>true</Filterable>
<Visible>true</Visible>
<VisibleInWebUI>true</VisibleInWebUI>
<Description/>
<isTime>false</isTime>
<Verify>false</Verify>
<Virtual>false</Virtual>
<Groupable>false</Groupable>
<SupportsMultivalue>false</SupportsMultivalue>
<CanChangeRequired>false</CanChangeRequired>
<Searchable>false</Searchable>
<VersionControlled>false</VersionControlled>
</Field>
-<Field Label="Test" Name="test-id" PhysicalName="RN_TEST_ID">
<Size>10</Size>
<Required>true</Required>
<Visible>true</Visible>
<System>true</System>
<Filterable>true</Filterable>
<Type>Number</Type>
<isTime>false</isTime>
<Verify>false</Verify>
<History>false</History>
<Virtual>false</Virtual>
<Active>false</Active>
<Editable>false</Editable>
<Groupable>false</Groupable>
<SupportsMultivalue>false</SupportsMultivalue>
<Searchable>false</Searchable>
<VersionControlled>false</VersionControlled>
-<References>
<RelationReference ReferencedEntityType="test" RelationName="runToTestUsage"/>
</References>
<VisibleInWebUI>true</VisibleInWebUI>
<Description/>
<CanChangeRequired>false</CanChangeRequired>
</Field>
-<Field Label="Test Instance" Name="testcycl-id" PhysicalName="RN_TESTCYCL_ID">
<Size>10</Size>
<History>true</History>
<Required>true</Required>
<System>true</System>
<Filterable>true</Filterable>
<Active>true</Active>
<Visible>true</Visible>
<Type>Reference</Type>
<isTime>false</isTime>
<Verify>false</Verify>
<Virtual>false</Virtual>
<Editable>false</Editable>
<Groupable>false</Groupable>
<SupportsMultivalue>false</SupportsMultivalue>
<Searchable>false</Searchable>
<VersionControlled>false</VersionControlled>
-<References>
<RelationReference ReferencedEntityType="test-instance" RelationName="testInstanceToRunRealization_mirrored"/>
</References>
<VisibleInWebUI>false</VisibleInWebUI>
<Description/>
<CanChangeRequired>false</CanChangeRequired>
</Field>
-<Field Label="Tester" Name="owner" PhysicalName="RN_TESTER_NAME">
<Size>60</Size>
<History>true</History>
<Required>true</Required>
<System>true</System>
<Type>UsersList</Type>
<Visible>true</Visible>
<Verify>true</Verify>
<VisibleInWebUI>true</VisibleInWebUI>
<Active>true</Active>
<Editable>true</Editable>
<Filterable>true</Filterable>
<Groupable>true</Groupable>
<isTime>false</isTime>
<SupportsMultivalue>false</SupportsMultivalue>
<Virtual>false</Virtual>
<Searchable>false</Searchable>
<VersionControlled>false</VersionControlled>
<Description/>
<CanChangeRequired>false</CanChangeRequired>
</Field>
</Fields>

Query for test-instances?query={cycle-id[123];test-id[4567]} lists the ResponseforAttachment File.

2) Could you please confirm with an example using POSTMAN to attach images to specific steps on the test?. i.e Image1 to Step1 and Image2 to Step2. 

0 Likes
singhHarmeet
New Member.

Re: How to create New Run using REST API ?

Jump to solution

ALM Create new Run with REST API getting HTTP 500 {"Id":"qccore.general-error","Title":"General Error","ExceptionProperties":null,"StackTrace":null}

Sending follownig fields

name, testcycl-id, cycle-id, test-config-id, name, owner, test-id, status, execution-date, execution-time, duration

Any Help will be appreciated.

0 Likes
pritesh Regular Contributor.
Regular Contributor.

Re: How to create New Run using REST API ?

Jump to solution

Currently I am facing issue with run step scenario execution through REST API.

Is anyone tried to update run steps  of any test case through REST API?

I am able to perform all the task like retriving test-set, test instances and run the test cases using rest api, but when I am trying to update run-steps getting 400 HTTPS response as bad request.

 

Please find below complete details.

 

  • First get request for run steps to retrieve exact data to update.

 

run_step_fields = "id,status,test-id,actual,description"

                        run_step_payload = {"query": "{}", "fields": run_step_fields,

                           "page-size": 100}

                        run_step_response = self.alm_session.get(self.base_url +  self.midPoint+ "/runs" + "/"+ temp_map['id']+"/run-steps", headers=self.headers,                              cookies=self.cookies,params=run_step_payload,verify=False)

 

Successfully retrieve  data

 

  • Then prepare data  to update xml ,created a PUT request

 

u'https://XXXXXXXXXXXX/qcbin/rest/domains/XXXXX/projects/XXXXXXX/runs/6390/run-steps/11836'

 

data

'<Entities><Entity Type="run-step"><Fields><Field Name="status"><Value>passed</Value></Field><Field Name="actual"><Value>batch id: 222</Value></Field><Field Name="id"><Value>11836</Value></Field><Field Name="description"><Value>&lt;html&gt;&lt;body&gt; \n&lt;div align="left" style="min-height:9pt"&gt;\n&lt;font face="Arial"&gt;&lt;span style="font-size:8pt"&gt;Verify that Workflow &lt;/span&gt;&lt;/font&gt;\n&lt;/div&gt;  \n&lt;/body&gt;&lt;/html&gt;</Value></Field></Fields></Entity></Entities>'

 

 

response = self.alm_session.put(self.base_url + self.midPoint + "/" + str_api, data=data,headers=headers,cookies=self.cookies,verify=False)

 

but getting below errors.

 

-> return response

response

<Response [400]>

response.content

'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r\n<html>\r\n\t<head>\r\n\t\t<title>Bad Request</title>\r\n\t\t<link rel="stylesheet" type="text/css" href="/qcbin/rest-exception/rest-exception.css"/>\r\n\t\t<script type="text/javascript" src="/qcbin/rest-exception/rest-exception.js"></script>\r\n\t</head>\r\n\t\r\n\t<body>\r\n\t\t<div id="banner">\r\n\t\t\t<img src="/qcbin/rest-exception/hp-logo.png" id="banner-logo"/>\r\n\t\t\t<h3 id="banner-title">HP Application Lifecycle Management</h3>\r\n\t\t</div>\r\n\t\t\r\n\t\t<div id="content-holder">\r\n\t\t\t<h1>Bad Request</h1>\r\n\t\t\t<div>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><a id="exception-id-title">Exception Id:</a></td>\r\n\t\t\t\t\t<td>qccore.general-error</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</div>\r\n\t\t\t<a id="more-details-label" style="display:none" href="#" onClick="javascript&colon;toggleDetails()">\r\n\t\t\t\t<h3>Show Details</h3>\r\n\t\t\t</a>\r\n\t\t\t<div id="details-holder" style="display:none">\r\n\t\t\t\t<div style="display:none">\r\n\t\t\t\t\t<h4>Exception Properties:</h4>\r\n\t\t\t\t\t<div></div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div style="display:none">\r\n\t\t\t\t\t<h4>Stack Trace:</h4>\r\n\t\t\t\t\t<div></div>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</body>\r\n</html>\r\n'

 

 

 

 

r any  solution for above error please suggest it, please verify my request data and let me know if I am missing anything on this code

 

Thanks

Pritesh

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: How to create New Run using REST API ?

Jump to solution

Hi Pritesh,

I've not yet updated run steps in ALM via REST - to analyze the error I'd reduce the statement to the bare minimum; e.g. only try to update the status. If that works I'd add more and more attributes.

Which ALM version are you using? Have you tried doing the same via OTA already? Perhaps there is a functional reason you cannot update specific fields?

Regards,

Dirk

0 Likes
pritesh Regular Contributor.
Regular Contributor.

Re: How to create New Run using REST API ?

Jump to solution

Hi Dirk

Thanks for quick reply. yes while troubleshooting i have applied same approach,

i have to do implementation using rest api  not through OTA so i am not checking that currently.

for run step i am trying to resolve that issue but since today i am getting new issue in creating  a run now i am getting 409 error code and says required fields missing but with same code yesterday and since today morning i have created too many runs , i dont know now why it is giving this issues?

i am using 12.21 version

is rest api not stable?

 

Thanks

Pritesh

 

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: How to create New Run using REST API ?

Jump to solution

Hi Pritesh,

I'd try to do the same with OTA just to verify this should work. During the development of the GDPR Content Pack I faced several situations where I thought something should work - just to find out there is a reason why something is not possible or blocked (e.g. linking specific item types, moving from one state to another only via a state in between etc.). And you might find more sample code for OTA than for REST, try how it works there, which attributes are mandatory, which exact format they have (sometimes date / time values were a challenge) and then move to REST.

Yes, the REST API is stable: If the code worked yesterday I don't see a reason why it should not work today (you are using exactly the same PC, the same ALM server, did not install anything relevant on the machine, did not add new mandatory fields, linked to a new template etc.?).

You should have in mind that there is the "official" REST API and the "technology preview" API: There are some disclaimers than the tech preview API could me less stable that the "official" public API.

Regards,

Dirk

0 Likes
pritesh Regular Contributor.
Regular Contributor.

Re: How to create New Run using REST API ?

Jump to solution

Hi Dirk

 

Thanks for detail reply. 

first sorry for wrong question ask about my yesterday code was not working today, it is working correctly without any issue..

regarding your suggestion for use of OTA before jump to rest  i understand ,but my project requirement is to implement through rest api only so thats why i am going through REST.

i have try with single field, multiple fields but its not still find me root cause of this error.

 https resonse < 400> Bad Request

i will contiue to look into this issue. but it is strange issue as it allows to retrive a run-step records using GET request but not allowing to update the data using "PUT " REQUEST is not easy to belive.

so i will contiue to troubleshoot and  find  out the root cause of this  error and  then solve the issue.

 

thanks again for your response.

 

 

 

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: How to create New Run using REST API ?

Jump to solution

Hi Pritesh,

Sure, I understand your final code must use the REST API. Nevertheless I'd try to do exactly the same with OTA first. It does not work with OTA? Then perhaps there is a reason why it does not work. It works but with different values / data types than expected? This will help solve it with the REST API as well, right?

You could use my GDPR Content Pack as a starter: For ALM/QC it creates both an OTA and a REST API connection since some elements / features are not yet available via REST (e.g. create a new requirement type, set a req type icon etc.). Then you could add your experiments to verify it's working via OTA. And yes I know: VBA is a very strange programming language, but Excel is available on so many Windows systems ;-)

Regards,

Dirk

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.