How to download attachments from JIRA v6.3.15 in java - jira

I'm trying to get list of JIRA issues created after a given date and download the respective attachment files from my application in java. The JIRA Server version I am currently using is 6.3.15.
When I searched on web I found the below REST client, however it says it supports till JIRA Server 6.0. I want to know whether it supports 6.3.15 as well, if not are there any other alternate solutions?
REST Java Client for JIRA
by Atlassian Labs for JIRA Server 5.0 - 6.0
https://marketplace.atlassian.com/plugins/com.atlassian.jira.jira-rest-java-client

REST Java Client for JIRA is a wrapper around JIRA REST https://docs.atlassian.com/jira/REST/6.3.15/.
I see that there was no changes in attachment REST methods between 6.0 and 6.3.15. Take the current version and I am sure it will work for you.
Another way is to directly use JIRA REST API and in your case it can be even simpler. I guess you need:
call https://YOUR_JIRA/rest/api/2/issue/CURRENT-ISSUE?fields=attachment for one issue or
https://YOUR_JIRA/rest/api/2/search?jql=YOUR_JQL&fields=attachment to return set of issues matching JQL query (make sure to take care about paging if you expect more than 1000 issues)
For each issue there will be a section with attachments:
"attachment":
[
{
"self": "https://vkrupach.atlassian.net/rest/api/2/attachment/10100",
"id": "10100",
"filename": "to test",
"author":
{
"self": "https://vkrupach.atlassian.net/rest/api/2/user?username=vkrupach",
"name": "vkrupach",
"key": "vkrupach",
"emailAddress": "vkrupach#ukr.net",
"avatarUrls":
{
"48x48": "https://vkrupach.atlassian.net/secure/useravatar?avatarId=10122",
"24x24": "https://vkrupach.atlassian.net/secure/useravatar?size=small&avatarId=10122",
"16x16": "https://vkrupach.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122",
"32x32": "https://vkrupach.atlassian.net/secure/useravatar?size=medium&avatarId=10122"
},
"displayName": "Volodymyr Krupach [Administrator]",
"active": true,
"timeZone": "Europe/Moscow"
},
"created": "2015-04-19T10:05:59.696+0300",
"size": 469,
"mimeType": "text/html",
"content": "https://vkrupach.atlassian.net/secure/attachment/10100/to+test"
}
]
"content": is direct link to file.

Related

Can't add Teams bot to a channel

This was originally a support ticket to Microsoft. However they told they don't do dev support without paying for it. They directed me to Stack Overflow, so here goes nothing.
I'm developing a Bot for Microsoft Teams. I have registered my bot with Azure Active Directory, & Bot Framework. I have uploaded my app to Team, without any errors. My bot is currently able to send direct messages to Teams users. However, when I try to add my bot to a Teams channel, I get unhelpful errors.
I click the dropdown under my app in the Apps tab:
I click "Add to a Team", then select a channel:
After clicking the button "Set up a bot", I get the following error message:
I have checked & rechecked my webApplicationInfo.id & webApplicationInfo.applicationPermissions numerous times, and I'm at a loss for what could be amiss. I don't see how either of these fields could be wrong given, I can authenticate with both the Microsoft Graph & Bot Framework apis using these values. Here's a slightly redacted version of my Teams app manifest:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.8/MicrosoftTeams.schema.json",
"manifestVersion": "1.8",
"version": "1.0.15",
"id": "<TEAMS_APP_ID>",
"packageName": "ambition",
"developer": {
"name": "Ambition",
"websiteUrl": "https://ambition.com",
"privacyUrl": "https://ambition.com/privacy",
"termsOfUseUrl": "https://ambition.com/pages/terms"
},
"icons": {
"color": "logo_opaque_192x192.png",
"outline": "logo_transparent_32x32.png"
},
"name": {
"short": "Ambition",
"full": ""
},
"description": {
"short": "Motivate & Recognize",
"full": "Ask Marketing"
},
"accentColor": "#FFFFFF",
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"ambition.com"
],
"bots": [
{
"botId": "<AZURE_ACTIVE_DIRECTORY_CLIENT_ID>",
"scopes": [
"team",
"personal",
"groupchat"
],
"isNotificationOnly": true
}
],
"webApplicationInfo": {
"id": "<AZURE_ACTIVE_DIRECTORY_CLIENT_ID>",
"resource": "https://ambition.com",
"applicationPermissions": [
"Channel.ReadBasic.All",
"ChannelMessage.Send",
"Group.Read.All",
"Notifications.ReadWrite.CreatedByApp",
"Team.ReadBasic.All",
"User.Read",
"User.ReadBasic.All"
]
}
}
The webApplicationInfo section is really only for two things: Tab SSO, and Resource-Specific Consent. Are you trying to implement either one of those? If not, removing it is definitely the best option, as you've noted in your answer.
In addition, I see that the resource values you've put in there are Microsoft Graph Scopes, whereas the applicationPermissions section is expecting a different list of options (they look kind of similar, but their not the same thing). See here for more: https://learn.microsoft.com/en-gb/microsoftteams/platform/graph-api/rsc/resource-specific-consent#resource-specific-permissions
Don't really know why this works, but I compared my app manifest to the one generated by going through this tutorial: https://learn.microsoft.com/en-us/microsoftteams/platform/build-your-first-app/build-bot.
Removing the webApplicationInfo property from my manifest fixed the issue. Don't really understand why it was causing a problem in the first place.
https://learn.microsoft.com/en-us/microsoftteams/platform/resources/schema/manifest-schema#webapplicationinfo

Modify Task.json at build step design time

i wanted to modify task.json on runtime means when i configure my CI task in vsts or tfs.
I created an extension that contribute a build task.
Through this build task i wanted to do something like this, i have done in jenkins. Please Refer screenshot:
1-Requirement) in this image we add global variable(fields) at runtime on clicking Add Global Variables button. It generates two fields one for GVName and another for its value.
2-Requirement) When we select global variable then respective value field change at runtime means it can be dropbox(picklist) or input field that depends on GV type.
3-Requirement) On Job design time we make an ajax call to server that return true/false on based of value we shows error like in image 2.
Is these requirements are feasible in VSTS task.json? If yes, can you help me to solve this.
No, but it can list the available items that returned from the server.
For example:
"inputs": [
{
"name": "APIURL",
"type": "connectedService:Generic",
"label": "API URL",
"required": true,
"helpMarkDown": ""
},
{
"name": "List1",
"type": "pickList",
"label": "List4",
"defaultValue": "",
"required": false,
"helpMarkDown": ""
}
],
"sourceDefinitions": [
{
"target": "List1",
"endpoint": "home/jsontest",
"selector": "jsonpath:$[*].id",
"authKey": "$(APIURL)"
}
],
A thread that may benefit you: Using a web API in task.json to fill picklists buildtask

Getting project category based on project key from jira rest api

We are developing a web project to get a list of project category for a particular project key for jira using their rest api and update it.
I can not find any appropriate api for the same.
Has anybody done something like this.
Thanks in advance.
The JIRA REST API documentation mentions this plain and simple.
Retrieving project info
Use GET /rest/api/2/project/{projectIdOrKey} to get details about a specific project. This response will also contain info about the project category, ie.:
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
Updating a project
To update the category, use PUT /rest/api/2/project/{projectIdOrKey}
You can include the id of the desired category in the request body, ie.:
{
"key": "EX",
"name": "Example",
"projectTypeKey": "business",
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-project-management",
"description": "Example Project description",
"lead": "Charlie",
"url": "http://atlassian.com",
"assigneeType": "PROJECT_LEAD",
"avatarId": 10200,
"issueSecurityScheme": 10001,
"permissionScheme": 10011,
"notificationScheme": 10021,
"categoryId": 10120
}

Visual Studio error when trying to create MVC application on Azure

I want to create a new MVC application with Visual Studio Community 2015. I've followed this tutorial on how to do this and I've gone as far as creating the application, but after I click 'Create' to create the application, the error message below is displayed.
Is this message referring to the Azure API version for Visual Studio? If so, how should I resolve this? I've looked online and I can't seem to find anything about this error. I'm a newbie at this, so I'm not sure if I've overlooked anything, but I don't seem to according to the tutorial. Any help is greatly appreciated!
UPDATE
The image below shows the SQL API version I've found. It's odd thought, because it does not match the version shown in the error message.
As the error message says the API have to be in correct format yyyy-MM-dd.
API version I was using recently was 2014-04-01 or 2014-04-01-preview. Try any of these when defining SqlServer resouce.
Also have a look at resources.azure.com if you have any SqlServers created and double check the API version from there..
This does not relate to the Azure Sdk version for Visual Studio. It relates to the (in your case) API version used to create SqlServer instance using Azure Resource Manager
Sample SqlServer and database resource node:
"resources": [
{
"name": "[parameters('sqlServerName')]",
"type": "Microsoft.Sql/servers",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [ ],
"tags": {
"displayName": "SqlServer"
},
"properties": {
"administratorLogin": "[parameters('sqlDatabaseUserName')]",
"administratorLoginPassword": "[parameters('sqlDatabasePassword')]",
"version": "12.0"
},
"resources": [
{
"name": "AllowAllWindowsAzureIps",
"type": "firewallrules",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('sqlServerName'))]"
],
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
}
},
{
"name": "[parameters('databaseName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"kind": "v12.0",
"dependsOn": [
"[parameters('sqlServerName')]"
],
"tags": {
"displayName": "SqlDatabase"
},
"properties": {
"collation": "[parameters('sqlDatabaseUriNameCollation')]",
"edition": "[parameters('sqlDatabaseUriNameEdition')]",
"maxSizeBytes": "10737418240"
//10 gigs currently
}
}
]
}
Also as #Robert McKee pointed make sure you have latest Azure SDK (2.7.1 or 2.8 released recently)
I'm not sure how, but this evening when I went to try it again, it worked. Thank you all for your answers!

How to get "Project Id" to create a Direct Link?

I have my project name, but not the numeric Project Id. The latter is needed to use HTML Direct Links.I'm using JIRA 5.0.1
How do I get the numeric Project Id for a given project name?
I've searched the Project Administration area, several other places, the documentation, Google, etc but still can't find a way to get that value.
Thanks.
This solution does not require admin rights:
Navigate to https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME and read the id in the JSON response:
{
"self":"https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME",
"id":"12345", ☜ Project Id
"key":"YOURPROJECTNAME",
"description":..
:
}
Navigate to https://jira.YOURDOMAIN.TLD/rest/api/2/project to get a JSON list of projects.
Bonus: here's a one-liner in Groovy to get the ID:
groovy -e "println new groovy.json.JsonSlurper().parseText("https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME".toURL().text)?.id ?: 'not found'"
A java.io.FileNotFoundException probably means that your JIRA server requires authentication.
Here's a one-liner to list all the visible projects and their ID:
groovy -e "new groovy.json.JsonSlurper().parseText('https://jira.YOURDOMAIN.TLD/rest/api/2/project'.toURL().text)?.each{println it.key+' = '+it.id}"
The easiest way is to do it from the web browser:
Go to the Administration page.
Select the Project from the menu.
Hover over 'Edit Project' link and check the link href (in the status bar).
It should be something like http://servername:8080/secure/project/EditProject!default.jspa?pid=10040
Where pid is the id you are looking for.
For Jira 6.x:
place the cursor on EDIT Project button and
look at the url being redirected at bottom left of the screen
This solution doesn't require admin rights and shows you all of the projects the current user can view.
https://example.com/rest/api/2/project
Responses found here.
https://docs.atlassian.com/jira/REST/latest/#d2e4972
returns a json array.
[
{
"self": "http://www.example.com/jira/rest/api/2/project/EX",
"id": "10000",
"key": "EX",
"name": "Example",
"avatarUrls": {
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
},
{
"self": "http://www.example.com/jira/rest/api/2/project/ABC",
"id": "10001",
"key": "ABC",
"name": "Alphabetical",
"avatarUrls": {
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10001",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10001",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10001",
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10001"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
}
]
Exporting a ticket in XML reveals the project ID for me. I am not admin, so can't access the admin page. The rest/json trick didn't work for me, either. The XML of an issue has the following,
<project id="1234" key="test">TEST Project</project>

Resources