Hi, I'm trying to use the JIRA rest API to get the issue is moved on one status to another, however, for all queries that I tried it returns 404 status.
An example http://localhost:8080/rest/attach-cat/1.0/attachments/get?issueKey=" +issue, however, it returns 404.
And Jira is 7.13.0
http://host:port/context/rest/api-name/api-version/resource-name
https://jira.atlassian.com/rest/api/latest/issue/JRA-9
Please check
https://developer.atlassian.com/server/jira/platform/rest-apis/
Hi Tomas Gustavsson,
Actually, I am using Smart attachment plugin 2.3.0 version and I am updating Meta Validation Plugin and that using URI http://localhost:8080/rest/attach-cat/1.0/attachments/get?issueKey=" +issue for getting the issue id's, however, it returns HTTP Failed Error Code is 404. then how to solve this error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you,
Tomas Gustavsson,
, for replying me. and now following link is working:
String urlCAL="http://192.168.1.236:8082/rest/api/2/attachment/"+issue;
but still, the same error has occurred. can you tell me please what can i change for following code to give me a list of attached files ?:
==========================
try
{
String authString = "vpsvalidator:8c5ydjGL0S8ZiZsODG2JetNqn";
String authStringEnc = Base64.getEncoder().encodeToString(authString.getBytes("utf-8"));
URL url = new URL(urlCAL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Authorization", "Basic " + authStringEnc);
if (conn.getResponseCode() != 200)
{
throw new RuntimeException("Failed : HTTP error code : "+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
String output = org.apache.commons.io.IOUtils.toString(br);
Pattern folderpattern = Pattern.compile("\"id\":(.+?),\"name\":\"(.+?)\",\"attachments\":(.+?)]") ;
Matcher foldermatch = folderpattern.matcher(output);
message1 = message1+ output;
while(foldermatch.find())
{
String attachmentsID = foldermatch.group(1);
String attachmentsFolders = foldermatch.group(2);
String attachmentsDetails = foldermatch.group(3);
if(attachmentsFolders.contains(requiredValue))
{
String folderFiles1 =attachmentsDetails.replace("{","");
String folderFiles2 =folderFiles1.replace("[","");
String folderFiles3 =folderFiles2.replaceAll("\"","");
folderFiles =folderFiles3.replace("ids:","");
message1= message1+folderFiles;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new InvalidInputException(e+"Unable to Find the Selected folder"+message1+"---"+folderFiles+"==="+requiredValue);
}
==================
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To get the Attachments, you need to have the attachments id. ex like below.
https://jira/rest/api/2/attachment/139053
so first you need to find the issue and see if i holds any attachments, and then get the attachments Id, then you can use that to request it.
some more info here
https://community.atlassian.com/t5/Jira-questions/How-to-retrieve-an-issue-attachments-with-the-rest-api/qaq-p/572084
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Tomas for understanding my concept and I want to use the GET method to find the issue and see if I hold any attachments, and then get the attachments Id then what I need to do change the below code :
String authString = "vpsvalidator:8c5ydjGL0S8ZiZsODG2JetNqn";
String authStringEnc = Base64.getEncoder().encodeToString(authString.getBytes("utf-8"));
URL url = new URL(urlCAL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Authorization", "Basic " + authStringEnc);
if (conn.getResponseCode() != 200)
{
throw new RuntimeException("Failed : HTTP error code : "+ conn.getResponseCode());
}
br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
message1 = message1+ org.apache.commons.io.IOUtils.toString(br);
folderpattern = Pattern.compile("\"id\":(.+?),\"name\":\"(.+?)\",\"attachments\":(.+?)]");
Matcher foldermatch = folderpattern.matcher(message1);
while(foldermatch.find())
{
String attachmentsID = foldermatch.group(1);
String attachmentsFolders = foldermatch.group(2);
String attachmentsDetails = foldermatch.group(3);
if(attachmentsFolders.contains(requiredValue))
{
String folderFiles1 =attachmentsDetails.replace("{","");
String folderFiles2 =folderFiles1.replace("[","");
String folderFiles3 =folderFiles2.replaceAll("\"","");
folderFiles =folderFiles3.replace("ids:","");
message1= message1+folderFiles;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new InvalidInputException(e+"--Unable to Find the Selected folder");
}
can you suggest to me?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.