Attachments
Manage attachments in TeamPulse.
GET /attachments/{id} - Get an attachment by ID
GET /attachments - Get all comments for the work items to which the user has access to.
GET /workitems/{workItemId}/attachments - Get all attachments for a work item
GET /comments/{commentId}/attachments - Get all attachments for a comment
POST /workitems/{workItemId}/attachments - Upload an attachment
PUT /attachments/{id} - Update an attachment
DELETE /attachment/{id} - Delete an attachment
Attachment Model
The object representing a comment has the following properties:
id: integer (Read-only)
- ID of the comment.
projectId: integer (Read-only)
- ID of the project to which this attachment belongs to.
workItemId: integer (Read-only)
- ID of the work item to which the attachment belongs to.
commentId: integer (Read-only)
- ID of the comment if the attachment is part of a comment, otherwise is empty.
name: string (Read-only)
- The file name of the attachment.
description: string
- Attachment description.
size: integer (Read-only)
- The size of the attachment.
friendlySize string (Read-only)
- The size of the attachment formatted user-friendly.
url: string (Read-only)
- The streaming download URL of the attachment.
downloadUrl: string (Read-only)
- The download URL of the attachment.
type: string (Read-only)
- Attachment type. Valid values are "TeamPulse" and "Feedback". Default value is "TeamPulse".
createdBy: string
- The name of the user who created the attachment
createdAt: DateTime
- The date when the attachment is created
lastModifiedBy: string
- The name of the user who last modified the attachment
lastModifiedAt: DateTime
- The date when the attachment is last modified
Resource Url
To make API requests use the URL [teampulse]/api/v1 where [teampulse] is the URL to the TeamPulse instance which you want to manage via the API.
Example:
[teampulse]/api/v1/attachments
Get an attachment
GET /attachments/{id}
Response
HTTP/1.1 200
{
"id": 1,
"name": "text1.txt",
"projectId": 1,
"workItemId": 100,
"type": "TeamPulse",
"description": "Sample attachment",
"size": 780831,
"url": "http://teampulse/AttachmentStreaming/19/AttachmentName/text1.txt",
"downloadUrl": "http://teampulse/AttachmentDownload/19/AttachmentName/text1.txt",
"commentId": null,
"friendlySize": "762.53 KB",
"createdBy": "Paul Smith",
"createdAt": "2013-06-20T10:10:00",
"lastModifiedBy": "Paul Smith",
"lastModifiedAt": "2013-06-20T11:45:00"
}
Get attachments
GET /attachments : Get all attachments for the work items to which the user has access to.
GET /workitems/{workItemId}/attachments : Get all attachments for a work item
GET /comments/{commentId}/attachments : Get all attachments for a comment
OData $filter and $orderby options can be supplied to filter and order the results. $top and $skip to get top N items and skip the top M. Read more how to use the OData options
Response
HTTP/1.1 200
{
"totalResults": 3,
"top": 3,
"results": [
{
"id": 1,
"name": "text1.txt",
"projectId": 1,
"workItemId": 100,
"type": "TeamPulse",
"description": "Sample attachment",
"size": 780831,
"url": "http://teampulse/AttachmentStreaming/1/AttachmentName/text1.txt",
"downloadUrl": "http://teampulse/AttachmentDownload/1/AttachmentName/text1.txt",
"commentId": null,
"friendlySize": "762.53 KB",
"createdBy": "Paul Smith",
"createdAt": "2013-06-20T10:10:00",
"lastModifiedBy": "Paul Smith",
"lastModifiedAt": "2013-06-20T11:45:00"
},
{
"id": 2,
"name": "image1.jpg",
"projectId": 1,
"workItemId": 100,
"type": "TeamPulse",
"description": "Sample attachment image",
"size": 5,
"url": "http://teampulse/AttachmentStreaming/2/AttachmentName/image1.jpg",
"downloadUrl": "http://teampulse/AttachmentDownload/2/AttachmentName/image1.jpg",
"commentId": null,
"friendlySize": "5.00 B",
"createdBy": "Paul Smith",
"createdAt": "2013-06-20T10:10:00",
"lastModifiedBy": "Paul Smith",
"lastModifiedAt": "2013-06-20T11:45:00"
},
{
"id": 3,
"name": "text2.txt",
"projectId": 1,
"workItemId": 100,
"type": "TeamPulse",
"description": null,
"size": 100,
"url": "http://teampulse/AttachmentStreaming/3/AttachmentName/text2.txt",
"downloadUrl": "http://teampulse/AttachmentDownload/3/AttachmentName/text2.txt",
"commentId": null,
"friendlySize": "100.00 B",
"createdBy": "Paul Smith",
"createdAt": "2013-06-20T10:10:00",
"lastModifiedBy": "Paul Smith",
"lastModifiedAt": "2013-06-20T11:45:00"
}
]
}
Create an attachment
POST /workitems/{workItemId}/attachments?type=TeamPulse
Request
Parameters
type: Valid values are "TeamPulse" and "Feedback". Default value is "TeamPulse".
Headers
Accept: application/json
Content-Type: multipart/form-data; boundary=---159662540232479
Body
-----159662540232479
Content-Disposition: form-data; name="files"; filename="text1.txt"
Content-Type: text/plain
file data
-----159662540232479--
Response
HTTP/1.1 201
{
"id": 1,
"name": "text1.txt",
"projectId": 1,
"workItemId": 100,
"type": "TeamPulse",
"description": "Sample attachment",
"size": 780831,
"url": "http://teampulse/AttachmentStreaming/1/AttachmentName/text1.txt",
"downloadUrl": "http://teampulse/AttachmentDownload/1/AttachmentName/text1.txt",
"commentId": null,
"friendlySize": "762.53 KB",
"createdBy": "Paul Smith",
"createdAt": "2013-06-20T10:10:00",
"lastModifiedBy": "Paul Smith",
"lastModifiedAt": "2013-06-20T11:45:00"
}
Update an attachment
PUT /attachments/{id}
The update can be done partially so only the properties that need to be updated can be provided in the request.
Request
{
"description": "Sample description updated"
}
Response
HTTP/1.1 200
{
"id": 1,
"name": "text1.txt",
"projectId": 1,
"workItemId": 100,
"type": "TeamPulse",
"description": "Sample description updated",
"size": 780831,
"url": "http://teampulse/AttachmentStreaming/1/AttachmentName/text1.txt",
"downloadUrl": "http://teampulse/AttachmentDownload/1/AttachmentName/text1.txt",
"commentId": null,
"friendlySize": "762.53 KB",
"createdBy": "Paul Smith",
"createdAt": "2013-06-20T10:10:00",
"lastModifiedBy": "Paul Smith",
"lastModifiedAt": "2013-06-20T11:45:00"
}
Delete an attachment
DELETE /attachments/{id}
Response
HTTP/1.1 200