api - 如何使用 Bugzilla REST API 发布错误

标签 api rest bugzilla

如何报告 bugzilla rest api 的错误?以下文档指出错误对象或其某些字段必须包含在 POST 正文中。我曾尝试将字段添加为 POST 方法参数,但出现此错误“未提供用于创建的数据”,状态代码为 400。我的问题是如何在 POST 方法主体中包含错误对象或其某些字段?

https://wiki.mozilla.org/Bugzilla:REST_API:Methods#Create_new_bug_.28.2Fbug_POST.29

String serverURL = "https://api-dev.bugzilla.mozilla.org/test/latest";
        String product = "FoodReplicator";            
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(serverURL + "/bug?username=abc@xyz.com&password=123456);
        method.addParameter("product", "FoodReplicator");
        method.addParameter("component", "Salt");
        method.addParameter("summary", "testing");
        method.addParameter("version", "1.0");
        client.executeMethod(method);
        return method.getStatusCode() + " " + method.getResponseBodyAsString();

最佳答案

您需要将数据格式化为 JSON 而不是 post params。 create 的请求类型仍然是 POST,但 body 需要是 JSON。

关于api - 如何使用 Bugzilla REST API 发布错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3751635/

相关文章:

api - 需要带有关联预告片的电视/电影API

java - 期望使用改造开始对象错误

Bugzilla:软件错误:无法确定本地时区

python - 如何使用 python 和 XML-RPC 获取 Bugzilla 的评论和附件详细信息?

authentication - Bugzilla 缺少 super 用户信息

python - django api 用于在数据库中创建数据

node.js - 使用node.js在POST请求中发送URL编码的字符串

node.js - 环回 REST findById 不能正常工作

python - 在 python 中使用 azure REST api 将 Runbook 创建为草稿时,我遇到了错误...!

reactjs - Nextjs api "pages/api"在 Vercel 服务器上不起作用