如何使用 Bugzilla REST API 发布错误

发布于 2024-09-24 07:26:09 字数 1118 浏览 10 评论 0原文

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

https://wiki.mozilla.org/Bugzilla:REST_API:方法#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 + "/[email protected]&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();

How can I report a bug with bugzilla rest api? The following document states that the bug object or a some of its fields must be included in POST body. I have tried adding the fields as POST method parameters but i get this error "No data supplied for create" with status code 400. My question is that how can I include a bug object or some of its fields in the POST method body??

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 + "/[email protected]&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();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

椵侞 2024-10-01 07:26:09

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

You need to format your data as JSON instead of post params. The request type for create is still POST, but the body needs to be JSON.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文