4

如何使用 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();
4

1 回答 1

2

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

于 2011-04-11T13:20:13.980 回答