官方文档如下:
The Jira Cloud platform REST API
示例代码如下:
- public static void getUser() throws UnirestException {
- // This code sample uses the 'Unirest' library:
- // http://unirest.io/java.html
- HttpResponse<JsonNode> response = Unirest.get("https://jira.example.com/rest/api/2/user")
- .basicAuth("Name.Surname", Const.TOKEN)
- .header("Accept", "application/json")
- .queryString("username", "Abc.Def")
- .asJson();
-
- System.out.println(response.getBody());
- }
打印如下:
- {
- "avatarUrls": {
- "48x48": "https://jira.example.com/secure/useravatar?avatarId=10122",
- "24x24": "https://jira.example.com/secure/useravatar?size=small&avatarId=10122",
- "16x16": "https://jira.example.com/secure/useravatar?size=xsmall&avatarId=10122",
- "32x32": "https://jira.example.com/secure/useravatar?size=medium&avatarId=10122"
- },
- "displayName": "测试姓名(昵称)",
- "active": true,
- "timeZone": "Asia/Shanghai",
- "groups": {
- "size": 13,
- "items": []
- },
- "locale": "en_US",
- "emailAddress": "Name.Surname@example.com",
- "expand": "groups,applicationRoles",
- "deleted": false,
- "name": "Name.Surname",
- "self": "https://jira.example.com/rest/api/2/user?username=Name.Surname",
- "key": "JIRAUSER19571",
- "applicationRoles": {
- "size": 1,
- "items": []
- }
- }
做一个笔记