调试JIRA Rest Api调用

用户名

我正在尝试调用JIRA rest API。我使用HTTPBuilder调用服务器。但是我收到了400错误请求。在JIRA的日志中,我什么也看不到。

调试此问题的最佳方法是什么。吉拉告诉我,我必须启用什么日志记录,或者必须在哪里查看,这是什么问题。

客户端日志中的“我的要求”(常规)

2016-11-24 19:44:22,761 DEBUG  DefaultClientConnectionOperator - Connecting to jira.test.com:443
2016-11-24 19:44:23,097 DEBUG  RequestAddCookies - CookieSpec selected: best-match
2016-11-24 19:44:23,108 DEBUG  RequestAuthCache - Auth cache not set in the context
2016-11-24 19:44:23,108 DEBUG  RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
2016-11-24 19:44:23,108 DEBUG  DefaultHttpClient - Attempt 1 to execute request
2016-11-24 19:44:23,108 DEBUG  DefaultClientConnection - Sending request: POST /jira/rest/api/2/issue HTTP/1.1
2016-11-24 19:44:23,109 DEBUG  wire - >> "POST /jira/rest/api/2/issue HTTP/1.1[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "Accept: application/json[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "Authorization: Basic cG1hOmJlZmltZTQ3[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "Content-Type: application/json[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "Content-Length: 86[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "Host: jira.test.com:443[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "Connection: Keep-Alive[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "[\r][\n]"
2016-11-24 19:44:23,110 DEBUG  wire - >> "{"fields":{"project":{"key":"DEMO"},"summary":"REST Test","issuetype":{"name":"Bug"}}}"
2016-11-24 19:44:23,332 DEBUG  wire - << "HTTP/1.1 400 Bad Request[\r][\n]"
2016-11-24 19:44:23,337 DEBUG  wire - << "Date: Thu, 24 Nov 2016 18:44:23 GMT[\r][\n]"
2016-11-24 19:44:23,337 DEBUG  wire - << "Server: Apache-Coyote/1.1[\r][\n]"
2016-11-24 19:44:23,337 DEBUG  wire - << "X-AREQUESTID: 1184x11559x1[\r][\n]"
2016-11-24 19:44:23,337 DEBUG  wire - << "X-ASESSIONID: xxx[\r][\n]"
2016-11-24 19:44:23,338 DEBUG  wire - << "X-AUSERNAME: xxx[\r][\n]"
2016-11-24 19:44:23,338 DEBUG  wire - << "Cache-Control: no-cache, no-store, no-transform[\r][\n]"
2016-11-24 19:44:23,338 DEBUG  wire - << "X-Content-Type-Options: nosniff[\r][\n]"
2016-11-24 19:44:23,338 DEBUG  wire - << "Content-Type: application/json;charset=UTF-8[\r][\n]"
2016-11-24 19:44:23,338 DEBUG  wire - << "Set-Cookie: JSESSIONID=xxxx; Path=/jira/; HttpOnly[\r][\n]"
2016-11-24 19:44:23,338 DEBUG  wire - << "Set-Cookie: atlassian.xsrf.token=BH04-20JI-TPKW-BCOS|fd0f9908f0241d6289509e6c621348ee63ead9c9|lin; Path=/jira[\r][\n]"
2016-11-24 19:44:23,339 DEBUG  wire - << "Connection: close[\r][\n]"
2016-11-24 19:44:23,339 DEBUG  wire - << "Transfer-Encoding: chunked[\r][\n]"
2016-11-24 19:44:23,339 DEBUG  wire - << "[\r][\n]"
2016-11-24 19:44:23,341 DEBUG  DefaultClientConnection - Receiving response: HTTP/1.1 400 Bad Request

产生问题的代码如下:

HTTPBuilder jiraHttp = new HTTPBuilder(jiraEndpoint)
        jiraHttp.headers[ 'Authorization' ] = "Basic " + "$username:$password".getBytes('iso-8859-1').encodeBase64()
        jiraHttp.headers[ 'Content-Type' ] = "application/json"
        jiraHttp.ignoreSSLIssues();

        String issueString = "{\"fields\":{\"project\":{\"key\":\"10300\"},\"summary\":\"REST Test\",\"issuetype\":{\"key\":\"10004\"}}}";
        jiraHttp.post(contentType : 'application/json', path : '/jira/rest/api/2/issue', body: issueString);
用户名

该问题得到间接解决。我将HTTP库切换到Jersey。不幸的是,由于无法正常工作,我无法确定原始问题是什么。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章