1

Any sample code to create a new bug in Bugzilla using the restful webservice API? What I have done so far is using Postman to see how it works:

The simple json code:

{
    "product" : "TestProduct",
    "component" : "TestComponent",
    "summary" : "This is the best bug report",
    "version" : "unspecified",
    "description" : "This is the best GUI for reporting bugs"
}

This is the endpoint:

http://localhost/bugzilla/rest.cgi/rest/bug

The error log I'm getting:

{
  "code": 32614,
  "message": "A REST API resource was not found for 'POST /rest/bug'.",
  "documentation": "https://bugzilla.readthedocs.org/en/5.0/api/",
  "error": true
}
ken4ward
  • 2,246
  • 5
  • 49
  • 89
  • Didn't find a link to the WebService API in the answers, so here it is (for version 5.x): https://bugzilla.readthedocs.io/en/5.0/api/ – Pascal Nov 01 '21 at 15:04

3 Answers3

1

A sample example written in python, to create a bug in Bugzilla 5.x, using the rest API .

import requests

data = {
    "product" : "TestProduct",
    "component" : "TestComponent",
    "summary" : "This is the best bug report",
    "version" : "unspecified",
    "description" : "This is the best GUI for reporting bugs"
}
url_bz_restapi = 'http://localhost/bugzilla/rest.cgi/bug'
r = requests.post(url_bz_restapi, data=data)
N. Chamaa
  • 1,507
  • 3
  • 12
  • 22
0

Create a new token from the api " /rest/login?login=foo@example.com&password=toosecrettoshow "

import requests

url = 'http://localhost/bugzilla/rest.cgi/bug?token=GENERATED TOKEN' 
data = {   
"product" : "TestProduct",   
"component" : "TestComponent", 
"version" : "unspecified",   
"summary" : "'This is a test bug - please disregard",   
"alias" : "Somlias",   
"op_sys" : "All",  
"priority" : "---",   
"rep_platform" : "All" 
}

def create_bug(url,data):   
    test = requests.post(url,data=data)     
    return test.json()

create_bug(url,data)
0

Using Rest client

URL : http://IP/bugzilla/rest.cgi/bug

Method: POST

Basic Auth: token:gentoken

JSON :

{

"product" : "Ashok",

"component" : "Test",

"version" : "unspecified",

"summary" : "'This is a test bug - from JSON"

}

Ashok Parmar
  • 336
  • 4
  • 4