Using XMLRPC to create a bug in Bugzilla

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using XMLRPC to create a bug in Bugzilla

Ian C
This post has NOT been accepted by the mailing list yet.
I am attempting to create a bug in Bugzilla 3.2.7 using XMLRPC via the
stream_context_create() function in PHP 5.3.2.

The way I understand it I need 2 method calls: User.login and Bug.create.
The first one works fine,  but the second one always returns me the string "faultStringLogin RequiredfaultCode410".

The first method call seems to work and I get id15 returned, along with some XML containing a method response in which member name "id" is given value 15, in a struct.
That is all the information that is returned.
The documentation says that the login method returns:
"A set of http cookies is also sent with the response.
These cookies must be sent along with any future requests to the webservice, for the duration of the session." - but nowhere does it say how.
All I can see is the ID number, and I've tried many ways  of putting this back into the XML code of the Bug.create, but I keep getting the same error.

Here is my full code. If anybody has any experience in this, please let me know what I'm doing wrong. Many thanks.

<?php
$context = stream_context_create(array('http' => array(
    'method' => "POST",
    'header' => "Content-Type: text/xml",
    'content' => "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<methodCall>
<methodName>User.login</methodName>
<params>
<value><struct>
<member><name>login</name><value><string>(my email address)</string></value></member>
<member><name>password</name><value><string>(my password)</string></value></member>
<member><name>remember</name><value><boolean>1</boolean></value></member>
</struct></value>
</params>
</methodCall>"
)));
$file = file_get_contents("http://my-bugzilla-domain.com/xmlrpc.cgi", false, $context);

$context = stream_context_create(array('http' => array(
    'method' => "POST",
    'header' => "Content-Type: text/xml",
    'content' => "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<methodCall>
<methodName>Bug.create</methodName>
<params>
<value><struct>
<member><name>id</name><value><int>15</int></value></member>
</struct></value>
<value><struct>
<member><name>product</name><value><string>(my product)</string></value></member>
<member><name>component</name><value><string>Engine</string></value></member>
<member><name>summary</name><value><string>Creating a bug</string></value></member>
<member><name>version</name><value><string>latest</string></value></member>
<member><name>description</name><value><string>This is a description of the bug I'm trying to create.</string></value></member>
<member><name>op_sys</name><value><string>All</string></value></member>
<member><name>platform</name><value><string>PC</string></value></member>
<member><name>priority</name><value><string>P5</string></value></member>
<member><name>severity</name><value><string>trivial</string></value></member>
</struct></value>
</params>
</methodCall>"
)));
$file = file_get_contents("http://my-bugzilla-domain.com/xmlrpc.cgi", false, $context);
?>