Reputation: 2296
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
}
Upvotes: 1
Views: 2584
Reputation: 408
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"
}
Upvotes: 0
Reputation: 1
Create a new token from the api " /rest/[email protected]&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)
Upvotes: 0
Reputation: 1577
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)
Upvotes: 1