Smart Attachments - Add attachment to category via API

Rafał Nowakowski September 7, 2018

Hello, 

I am using Smart Attachments to group my Issues attachments into categories.

Now i need to add attachment to my Issue defining particular category of this Attachment via rest API. Is it possible? Below my siple code to add attachment. How should i modify that to be able to specify category? 

Your answers dont need to be in VBA, Just give me idea how to specify the category please.

 

Public Function testAuthen()
Dim JiraService As New MSXML2.XMLHTTP60

Dim sFileDataStr As String
sPath = "C:\Users\user1\Desktop\filename.pdf"
Const STR_BOUNDARY As String = "abc123-xyz123"


sFileDataStr = "--" & STR_BOUNDARY & vbCrLf & _
"Content-Disposition: form-data; name=""file"";Filename = """ & Mid$(sPath, InStrRev(sPath, "\") + 1) & """" & vbCrLf & _
"Content-Type: application/octet-stream" & vbCrLf & _
vbCrLf & GetFileBytes(sPath) & vbCrLf & "--" & _
STR_BOUNDARY & "--"


With JiraService

.Open "POST", "myurl/rest/api/2/issue/CERT-63/attachments", False

.setRequestHeader "X-Atlassian-Token:", "no-check"
.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & STR_BOUNDARY
.setRequestHeader "Authorization", "Basic " & UserPassBase64
.send stringToByteArray(sFileDataStr)
MsgBox JiraService.Status
MsgBox JiraService.responseText


End With
End Function

 

3 answers

0 votes
Rafał Nowakowski September 11, 2018

@Mohamed Benziane

Thanks for your reply, but it doesn't resolve my problem.

I need to add Attachment to Issue into particular category. 

I dont want manage attachment categories.

 

I know how to add attachment via API, but i dont know where i can specify category in wchich this new attachment should be attached. 

Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2018

Hello @Rafał Nowakowski

To add an attachment in a category you have to know its ID (you can follow what i said above)

you can may be try to Put attachments to categories before upload

 

Regards

Shweta August 27, 2019

Hello, I am trying to put attachment to catergory before upload.I am using SoapUI to achieve that, but I am getting 500 error code and "unrecognized character escape 'U'" as error message. Attached is the screenshot of the same.  What might be the reason for that? attachment_2.JPG

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 10, 2018

Hello Rafal

Yes you can add attachment in a specify category, you need to fetch category id, here the code:

curl -D- -u username:password --request GET "JIRA.baseUrl/rest/attach-cat/1.0/project/category?projectKey=PROJECT_KEY"

When you will be able to get the category id here the code to put you're attachment in the category

curl -D- -u username:password --request POST "JIRA.baseURL/rest/attach-cat/1.0/project/category" --data "projectKey=KEY&name=CategoryName&groups=groupName&users=username&roles=roleId&issueTypes=IssutTypeId" 

Here the required field:

projectkey, name, groups,users,roles,issuetypes

 

Everything is explained here

 

Sorry for my english

 

Hope this helps

Regards

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 10, 2018

Hello Rafal,

 

To add attachment to a specify category you have to get this ID and to fetch id category of a existing project here the code:

 

curl -D- -u username:password --request GET "JIRA.baseUrl/rest/attach-cat/1.0/project/category?projectKey=PROJECT_KEY"

 

You will receive a JSON document like this:

{   "categories":[      {         "id":0,         "name":"Uncategorized",         "position":0,         "groups":[],         "roles":[],         "issueTypes":[],         "users":[],         "userPosition":{}      },      {         "id":1,         "name":"Docs",         "position":1,         "groups":["jira-administrators"],         "roles":[10002],         "issueTypes":[10000],         "users":["admin"],         "userPosition":{}      }   ],   "disabled":false,   "imageSize":100,   "formDropZones":true}

Here more informations

 Sorry for my english

Hope this helps

Regards

Florian Reichl December 27, 2021

@Mohamed Benziane how about jira cloud?

Stiltsoft Support
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 28, 2021

@Florian Reichl 

You can group your attachments into different categories by label, uploader, or upload date using our Smart Attachments for Jira Cloud.

Please, see the documentation for more details.

Regards,

Elena Ovdienko

Product Manager@Stiltsoft

Florian Reichl December 28, 2021

@Stiltsoft Support  thank you for your quick answer - but are those distinctions available via any type of API in cloud?

Stiltsoft Support
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 28, 2021

These are the basic features of our app. No need to configure anything after setting up.

Suggest an answer

Log in or Sign up to answer