3

I am trying to open a new defect in QC using rest api

My code looks like below

createxml ='<Entity Type="defect">
<Fields>
     <Field Name="user-15">
          <Value>Development</Value>
     </Field>' ;

$qc = curl_init();
// create a cookie file
$ckfile = tempnam ("/tmp", "CURLCOOKIE");

// The authentication is done and also checks are done and after below code is executed to create a new defect in QC

$url ="http://host/qcbin/rest/domains/STANDARD_STRUCT/projects/Releases/defects/" ;

curl_setopt($qc, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($qc, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($qc, CURLOPT_HTTPHEADER, Array("Accept: application/xml"));
curl_setopt($qc, CURLOPT_URL, $url);
curl_setopt($qc, CURLOPT_POST, 1);
curl_setopt($qc, CURLOPT_POSTFIELDS,$createxml);
curl_setopt($qc, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($qc);

if(curl_errno($qc))
    print curl_error($qc) ;
else
    curl_close($qc) ;

echo $result ; `

Notice: Use of undefined constant http_code - assumed 'http_code' in C:\xampp\htdocs\createdef.php on line 150 200 the response is not created `

I am not able to figure out what is causing the issue .

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • $createxml =' Development ' ; – user3436222 Aug 14 '15 at 17:05
  • The above part is correct .however i am getting below error .Is is due to some configuration in setting up HP QC that i am not able to create the defect using REST .However i can do it from my user from QC . qccore.general-errorjavax.ws.rs.WebApplicationException at org.apache.wink.server.internal.registry.ResourceRegistry.filterDispatchMethods(ResourceRegistry.java:468) at org.apache.wink.server.internal.registry.ResourceRegistry.findMethod(ResourceRegistry.java:352) at org.apache.wink.server.intern. – user3436222 Aug 14 '15 at 17:06
  • g.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) Notice: Use of undefined constant http_code - assumed 'http_code' in C:\xampp\htdocs\createdef.php on line 150 200 the response is not created – user3436222 Aug 14 '15 at 17:08
  • I appreciate if any one attempts to help – user3436222 Sep 01 '15 at 12:43

1 Answers1

1

Two errors I can see are:

1)

 createxml ='<Entity Type="defect">
    <Fields>
         <Field Name="user-15">
              <Value>Development</Value>
         </Field>' ;

--> You have not closed the Fields. At least a proper check for xml can be added from you. I mean short xml creation for instance.

2) Remove the '/' sign at the end of your command line. You don't need that.

In case of creation a code 201 is replied from the ALM API. I know that long time passed, but hop to help a bit in the future!

Please check and have a nice day.

Marco smdm
  • 1,020
  • 1
  • 15
  • 25