Item Attachment Endpoint

Get

This method returns an attachment of a specific Item.

Get/api/items/{itemid}/attachments/{attachmentid}

The URL must have the Item Id and Attachment Id. It returns an IssueAttachmentDto.

Microsoft.NET example:

IssueAttachmentDto itemAttachment = serviceManager.Item.IssueAttachmentGet(36, 103);

JavaScript example:

var geminiUrl = "http://localhost/gemini/api/items/36/attachments/103";
var geminiUsername = Base64.encode("manager:xvitjc5bmm"); // user : apikey

$.ajax({
    url: geminiUrl,
    type: "GET",
    headers: { "Authorization": "Basic " + geminiUsername },
    success: function (data) {
      alert('Success!');
    }
});

Get All

This method returns all Attachments of a specific Item.

Get/api/items/{itemid}/attachments

It returns a list of IssueAttachmentDto's.

Microsoft.NET example:

List<IssueAttachmentDto> itemAttachments = serviceManager.Item.IssueAttachmentsGet(36);

JavaScript example:

var geminiUrl = "http://localhost/gemini/api/items/36/attachments";
var geminiUsername = Base64.encode("manager:xvitjc5bmm"); // user : apikey

$.ajax({
    url: geminiUrl,
    type: "GET",
    headers: { "Authorization": "Basic " + geminiUsername },
    success: function (data) {
      alert('Success!');
    }
});

Create

This method creates a new Attachment.

POST/api/items/{itemid}/attachments

The request body must contain the IssueAttachment entity. The return value is a new IssueAttachmentDto where the IssueAttachment Id field is populated.

Microsoft.NET example:

var attachments = new IssueAttachment();

attachments.Name = ""MyItems.txt"";
attachments.IssueId = 36;
attachments.ProjectId = 17;
attachments.Content = byteArray;
attachments.ContentType = "text/plain";

serviceManager.Item.IssueAttachmentCreate(attachments);

JavaScript example:

var geminiUrl = "http://localhost/gemini/api/items/36/attachments";
var geminiUsername = Base64.encode("manager:xvitjc5bmm"); // user : apikey
var geminiData = {
    ProjectId: "17",
    IssueId: "36",
    Name: "MyItems.txt",
    Content: byteArray,
    ContentType: "text/plain"
}

$.ajax({
    url: geminiUrl,
    type: "POST",
    data: geminiData,
    headers: { "Authorization": "Basic " + geminiLogin },
    success: function (data) {
      alert('Success!');
    }
});

Update

This method updates an existing Attachment.

PUT/api/items/{itemid}/attachments

The request body must contain the IssueAttachment entity including the Id. The return value is the updated IssueAttachmentDto.

Microsoft.NET example:

IssueAttachmentDto data = new IssueAttachmentDto();

data.Entity.Id = 58;
data.Entity.ProjectId = 17;
data.Entity.IssueId = 36;
data.Entity.Name = "MyItems.txt";
data.Entity.Content = byteArray;
data.Entity.ContentType = "text/plain";

serviceManager.Item.IssueAttachmentCreate(data.Entity);

JavaScript example:

var geminiUrl = "http://localhost/gemini/api/items/36/attachments";
var geminiUsername = Base64.encode("manager:xvitjc5bmm"); // user : apikey
var geminiData = {
    Id: "58",
    ProjectId: "17",
    IssueId: "36",
    Name: "MyItems.txt",
    Content: byteArray,
    ContentType: "text/plain"
}

$.ajax({
    url: geminiUrl,
    type: "PUT",
    data: geminiData,
    headers: { "Authorization": "Basic " + geminiLogin },
    success: function (data) {
      alert('Success!');
    }
});

Delete

This method deletes an Attachment

DELETE/api/items/{itemid}/attachments/{attachmentid}

The URL must contain the Item Id and Attachment Id.

Microsoft.NET example:

serviceManager.Item.IssueAttachmentDelete(36, 58);

JavaScript example:

var geminiUrl = "http://localhost/gemini/api/items/36/attachments/58;
var geminiUsername = Base64.encode("manager:xvitjc5bmm"); // user : apikey

$.ajax({
    url: geminiUrl,
    type: "DELETE",
    headers: { "Authorization": "Basic " + geminiUsername },
    success: function () {
      alert('Success!');
    }
});