I am not able to retrieve every information (such as comments, attachments, estimated time...) from a bug on Bugzilla (my version is 4.2.5) using it's Webservice. I have all the IDs of the bugs and am trying to access they're according URL to get the XML format of the bug.
I am told that the Bugzilla API doesn't allow access via cookies. So I have the following but I keep getting stuck at the login page even when providing the correct username and password. Here is what I have so far:
pf = {'username' : 'my_username', 'password' : 'my_password' }
fields = urllib.urlencode(pf)
pageContents = StringIO.StringIO()
p = pycurl.Curl()
p.setopt(pycurl.FOLLOWLOCATION, 1)
p.setopt(pycurl.COOKIEFILE, './cookie_test.txt')
p.setopt(pycurl.COOKIEJAR, './cookie_test.txt')
p.setopt(pycurl.POST, 1)
p.setopt(pycurl.POSTFIELDS, fields)
p.setopt(pycurl.WRITEFUNCTION, pageContents.write)
p.setopt(pycurl.VERBOSE, True)
p.setopt(pycurl.DEBUGFUNCTION, test)
p.setopt(pycurl.URL, 'https://somewebsite.com/viewXMLof=[ENTER-BUG-ID-HERE]')
p.perform()
p.close() # This is mandatory.
pageContents.seek(0)
for x in pageContents.readlines() :
print x
So what I get displayed is the following:
<html lang="en">
<head>
<title>Log in to Website</title>
.
.
.
This means that I am still at the login page. Any suggestions?
Let me know if further explanation is required.
Bugzilla uses XML-RPC or JSON-RPC. See https://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService.html and http://xmlrpc.scripting.com/spec
Using XML-RPC you need to POST an XML document to the mybugzilla.com/xmlrpc.cgi URL. Here is an example to get the Bugzilla time information.
<?xml version="1.0"?>
<methodCall>
<methodName>Bugzilla.time</methodName>
<params>
<param>
<struct>
<member>
<name>Bugzilla_login</name>
<value>user@example.com</value>
</member>
<member>
<name>Bugzilla_password</name>
<value>password</value>
</member>
</struct>
</param>
</params>
</methodCall>
To get a specific bug use the Bug.get method with a param element like this:
<param>
<struct>
<member>
<name>Bugzilla_login</name>
<value>user@example.com</value>
</member>
<member>
<name>Bugzilla_password</name>
<value>password</value>
</member>
<member>
<name>ids</name>
<value>
<array>
<data>
<value>
<int>1</int>
</value>
</data>
</array>
</value>
</member>
</struct>
</param>
Additionally you can use http://xmlrpc.devzing.com/ to help you test your XML-RPC calls and understand the responces.