Add one or more attachments to an issue. This example will add 3 attachments to the issue "SCRUM-15".
curl -X POST --user jira@example.com:JIRA_API_TOKEN \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--header 'X-Atlassian-Token: no-check' \
--form 'name=file; file=@starfish.jpg' \
--form 'name=file; file=@sample2.docx' \
--form 'name=file; file=@sample.pdf' \
--url 'https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/attachments'
Dim rest As New ChilkatRest
Dim success As Long
' URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/attachments
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("your-domain.atlassian.net",port,bTls,bAutoReconnect)
If (success <> 1) Then
Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
Debug.Print rest.LastErrorText
Exit Sub
End If
success = rest.SetAuthBasic("jira@example.com","JIRA_API_TOKEN")
rest.PartSelector = "1"
Dim fileStream1 As New ChilkatStream
fileStream1.SourceFile = "starfish.jpg"
success = rest.AddHeader("Content-Disposition","form-data; name=""file""; filename=""starfish.jpg""")
success = rest.AddHeader("Content-Type","image/jpeg")
success = rest.SetMultipartBodyStream(fileStream1)
rest.PartSelector = "2"
Dim fileStream2 As New ChilkatStream
fileStream2.SourceFile = "sample2.docx"
success = rest.AddHeader("Content-Disposition","form-data; name=""file""; filename=""sample2.docx""")
success = rest.AddHeader("Content-Type","application/vnd.openxmlformats-officedocument.wordprocessingml.document")
success = rest.SetMultipartBodyStream(fileStream2)
rest.PartSelector = "3"
Dim fileStream3 As New ChilkatStream
fileStream3.SourceFile = "sample.pdf"
success = rest.AddHeader("Content-Disposition","form-data; name=""file""; filename=""sample.pdf""")
success = rest.AddHeader("Content-Type","application/pdf")
success = rest.SetMultipartBodyStream(fileStream3)
rest.PartSelector = "0"
success = rest.AddHeader("Content-Type","multipart/form-data")
success = rest.AddHeader("X-Atlassian-Token","no-check")
success = rest.AddHeader("Accept","application/json")
Dim strResponseBody As String
strResponseBody = rest.FullRequestMultipart("POST","/rest/api/2/issue/SCRUM-15/attachments")
If (rest.LastMethodSuccess <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
Dim respStatusCode As Long
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Debug.Print "Response Status Code = " & respStatusCode
Debug.Print "Response Header:"
Debug.Print rest.ResponseHeader
Debug.Print "Response Body:"
Debug.Print strResponseBody
Exit Sub
End If
Dim jsonResponse As New ChilkatJsonArray
success = jsonResponse.Load(strResponseBody)
Dim arrIdx As Long
arrIdx = 0
Dim numArrayObjects As Long
numArrayObjects = jsonResponse.Size
' Iterate over the members of the array.
Do While arrIdx < numArrayObjects
' Make sure the array member at this index is a JSON object.
If (jsonResponse.TypeAt(arrIdx) = 3) Then
Dim jObj As ChilkatJsonObject
Set jObj = jsonResponse.ObjectAt(arrIdx)
' ...
End If
arrIdx = arrIdx + 1
Loop
[
{
"self": "https://chilkat.atlassian.net/rest/api/2/attachment/10001",
"id": "10001",
"filename": "starfish.jpg",
"author": {
"self": "https://chilkat.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"accountId": "557058:be8b47b5-3bc0-43f6-b6b2-2cca0de12204",
"emailAddress": "admin@@chilkatsoft.com",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "Chilkat Admin",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2018-04-13T10:04:44.966-0500",
"size": 6229,
"mimeType": "image/jpeg",
"content": "https://chilkat.atlassian.net/secure/attachment/10001/starfish.jpg",
"thumbnail": "https://chilkat.atlassian.net/secure/thumbnail/10001/starfish.jpg"
},
{
"self": "https://chilkat.atlassian.net/rest/api/2/attachment/10002",
"id": "10002",
"filename": "sample2.docx",
"author": {
"self": "https://chilkat.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"accountId": "557058:be8b47b5-3bc0-43f6-b6b2-2cca0de12204",
"emailAddress": "admin@@chilkatsoft.com",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "Chilkat Admin",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2018-04-13T10:04:45.706-0500",
"size": 21082,
"mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"content": "https://chilkat.atlassian.net/secure/attachment/10002/sample2.docx"
},
{
"self": "https://chilkat.atlassian.net/rest/api/2/attachment/10003",
"id": "10003",
"filename": "sample.pdf",
"author": {
"self": "https://chilkat.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"accountId": "557058:be8b47b5-3bc0-43f6-b6b2-2cca0de12204",
"emailAddress": "admin@@chilkatsoft.com",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "Chilkat Admin",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2018-04-13T10:04:46.292-0500",
"size": 178399,
"mimeType": "application/pdf",
"content": "https://chilkat.atlassian.net/secure/attachment/10003/sample.pdf"
}
]