Attachments - Create
Uploads an attachment.
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?api-version=4.1
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName={fileName}&uploadType={uploadType}&areaPath={areaPath}&api-version=4.1
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
organization
|
path | True |
string |
The name of the Azure DevOps organization. |
project
|
path |
string |
Project ID or project name |
|
api-version
|
query | True |
string |
Version of the API to use. This should be set to '4.1' to use this version of the api. |
area
|
query |
string |
Target project Area Path |
|
file
|
query |
string |
The name of the file |
|
upload
|
query |
string |
Attachment upload type: Simple or Chunked |
Request Body
Media Types: "application/octet-stream"
Name | Type | Description |
---|---|---|
body |
string (Stream) |
Stream to upload |
Responses
Name | Type | Description |
---|---|---|
200 OK |
successful operation |
Security
oauth2
Type:
oauth2
Flow:
accessCode
Authorization URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
Scopes
Name | Description |
---|---|
vso.work_write | Grants the ability to read, create, and update work items and queries, update board metadata, read area and iterations paths other work item tracking related metadata, execute queries, and to receive notifications about work item events via service hooks. |
Examples
Chunked Upload Step #1 |
Chunked Upload Step #2 |
Chunked Upload Step #3 |
Upload a binary file |
Upload a text file |
Chunked Upload Step #1
Sample request
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=largefile.zip&uploadType=chunked&api-version=4.1
Sample response
{
"id": "de471719-27b2-40ab-ac40-4890f3eb1443",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/de471719-27b2-40ab-ac40-4890f3eb1443?fileName=test.txt"
}
Chunked Upload Step #2
Sample request
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?uploadType=chunked&api-version=4.1
"{zip content chunk 1}"
Sample response
{
"id": "de471719-27b2-40ab-ac40-4890f3eb1443",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/de471719-27b2-40ab-ac40-4890f3eb1443"
}
Chunked Upload Step #3
Sample request
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?uploadType=chunked&api-version=4.1
"{zip content chunk 2}"
Sample response
{
"id": "de471719-27b2-40ab-ac40-4890f3eb1443",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/de471719-27b2-40ab-ac40-4890f3eb1443"
}
Upload a binary file
Sample request
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=imageAsFileAttachment.png&api-version=4.1
{
"0": 137,
"1": 80,
"2": 78,
"3": 71,
"4": 13,
"5": 10,
"6": 26,
"7": 10,
"8": 0,
"9": 0,
"10": 0,
"11": 13,
"12": 73,
"13": 72,
"14": 68,
"15": 82,
"16": 0,
"17": 0,
"18": 0,
"19": 24,
"20": 0,
"21": 0,
"22": 0,
"23": 24,
"24": 8,
"25": 2,
"26": 0,
"27": 0,
"28": 0,
"29": 111,
"30": 21,
"31": 170,
"32": 175,
"33": 0,
"34": 0,
"35": 0,
"36": 1,
"37": 115,
"38": 82,
"39": 71,
"40": 66,
"41": 0,
"42": 174,
"43": 206,
"44": 28,
"45": 233,
"46": 0,
"47": 0,
"48": 0,
"49": 4,
"50": 103,
"51": 65,
"52": 77,
"53": 65,
"54": 0,
"55": 0,
"56": 177,
"57": 143,
"58": 11,
"59": 252,
"60": 97,
"61": 5,
"62": 0,
"63": 0,
"64": 0,
"65": 9,
"66": 112,
"67": 72,
"68": 89,
"69": 115,
"70": 0,
"71": 0,
"72": 14,
"73": 195,
"74": 0,
"75": 0,
"76": 14,
"77": 195,
"78": 1,
"79": 199,
"80": 111,
"81": 168,
"82": 100,
"83": 0,
"84": 0,
"85": 0,
"86": 101,
"87": 73,
"88": 68,
"89": 65,
"90": 84,
"91": 56,
"92": 79,
"93": 237,
"94": 204,
"95": 65,
"96": 10,
"97": 192,
"98": 32,
"99": 12,
"100": 68,
"101": 81,
"102": 239,
"103": 127,
"104": 105,
"105": 27,
"106": 240,
"107": 167,
"108": 24,
"109": 146,
"110": 52,
"111": 22,
"112": 138,
"113": 80,
"114": 240,
"115": 237,
"116": 156,
"117": 140,
"118": 211,
"119": 250,
"120": 71,
"121": 206,
"122": 80,
"123": 109,
"124": 227,
"125": 80,
"126": 83,
"127": 188,
"128": 19,
"129": 213,
"130": 217,
"131": 34,
"132": 141,
"133": 164,
"134": 55,
"135": 190,
"136": 70,
"137": 104,
"138": 88,
"139": 73,
"140": 90,
"141": 161,
"142": 55,
"143": 137,
"144": 162,
"145": 53,
"146": 180,
"147": 213,
"148": 198,
"149": 33,
"150": 210,
"151": 60,
"152": 31,
"153": 130,
"154": 33,
"155": 65,
"156": 87,
"157": 249,
"158": 68,
"159": 140,
"160": 230,
"161": 109,
"162": 105,
"163": 200,
"164": 163,
"165": 55,
"166": 249,
"167": 203,
"168": 144,
"169": 224,
"170": 71,
"171": 132,
"172": 134,
"173": 149,
"174": 14,
"175": 9,
"176": 254,
"177": 89,
"178": 220,
"179": 156,
"180": 167,
"181": 161,
"182": 87,
"183": 206,
"184": 80,
"185": 165,
"186": 247,
"187": 11,
"188": 116,
"189": 99,
"190": 71,
"191": 0,
"192": 204,
"193": 122,
"194": 63,
"195": 206,
"196": 0,
"197": 0,
"198": 0,
"199": 0,
"200": 73,
"201": 69,
"202": 78,
"203": 68,
"204": 174,
"205": 66,
"206": 96,
"207": 130,
"208": 0,
"209": 0,
"BYTES_PER_ELEMENT": 1,
"buffer": {
"0": 137,
"1": 80,
"2": 78,
"3": 71,
"4": 13,
"5": 10,
"6": 26,
"7": 10,
"8": 0,
"9": 0,
"10": 0,
"11": 13,
"12": 73,
"13": 72,
"14": 68,
"15": 82,
"16": 0,
"17": 0,
"18": 0,
"19": 24,
"20": 0,
"21": 0,
"22": 0,
"23": 24,
"24": 8,
"25": 2,
"26": 0,
"27": 0,
"28": 0,
"29": 111,
"30": 21,
"31": 170,
"32": 175,
"33": 0,
"34": 0,
"35": 0,
"36": 1,
"37": 115,
"38": 82,
"39": 71,
"40": 66,
"41": 0,
"42": 174,
"43": 206,
"44": 28,
"45": 233,
"46": 0,
"47": 0,
"48": 0,
"49": 4,
"50": 103,
"51": 65,
"52": 77,
"53": 65,
"54": 0,
"55": 0,
"56": 177,
"57": 143,
"58": 11,
"59": 252,
"60": 97,
"61": 5,
"62": 0,
"63": 0,
"64": 0,
"65": 9,
"66": 112,
"67": 72,
"68": 89,
"69": 115,
"70": 0,
"71": 0,
"72": 14,
"73": 195,
"74": 0,
"75": 0,
"76": 14,
"77": 195,
"78": 1,
"79": 199,
"80": 111,
"81": 168,
"82": 100,
"83": 0,
"84": 0,
"85": 0,
"86": 101,
"87": 73,
"88": 68,
"89": 65,
"90": 84,
"91": 56,
"92": 79,
"93": 237,
"94": 204,
"95": 65,
"96": 10,
"97": 192,
"98": 32,
"99": 12,
"100": 68,
"101": 81,
"102": 239,
"103": 127,
"104": 105,
"105": 27,
"106": 240,
"107": 167,
"108": 24,
"109": 146,
"110": 52,
"111": 22,
"112": 138,
"113": 80,
"114": 240,
"115": 237,
"116": 156,
"117": 140,
"118": 211,
"119": 250,
"120": 71,
"121": 206,
"122": 80,
"123": 109,
"124": 227,
"125": 80,
"126": 83,
"127": 188,
"128": 19,
"129": 213,
"130": 217,
"131": 34,
"132": 141,
"133": 164,
"134": 55,
"135": 190,
"136": 70,
"137": 104,
"138": 88,
"139": 73,
"140": 90,
"141": 161,
"142": 55,
"143": 137,
"144": 162,
"145": 53,
"146": 180,
"147": 213,
"148": 198,
"149": 33,
"150": 210,
"151": 60,
"152": 31,
"153": 130,
"154": 33,
"155": 65,
"156": 87,
"157": 249,
"158": 68,
"159": 140,
"160": 230,
"161": 109,
"162": 105,
"163": 200,
"164": 163,
"165": 55,
"166": 249,
"167": 203,
"168": 144,
"169": 224,
"170": 71,
"171": 132,
"172": 134,
"173": 149,
"174": 14,
"175": 9,
"176": 254,
"177": 89,
"178": 220,
"179": 156,
"180": 167,
"181": 161,
"182": 87,
"183": 206,
"184": 80,
"185": 165,
"186": 247,
"187": 11,
"188": 116,
"189": 99,
"190": 71,
"191": 0,
"192": 204,
"193": 122,
"194": 63,
"195": 206,
"196": 0,
"197": 0,
"198": 0,
"199": 0,
"200": 73,
"201": 69,
"202": 78,
"203": 68,
"204": 174,
"205": 66,
"206": 96,
"207": 130,
"208": 0,
"209": 0,
"byteLength": 210
},
"length": 210,
"byteOffset": 0,
"byteLength": 210
}
Sample response
{
"id": "a5cedde4-2dd5-4fcf-befe-fd0977dd3433",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/a5cedde4-2dd5-4fcf-befe-fd0977dd3433?fileName=imageAsFileAttachment.png"
}
Upload a text file
Sample request
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=textAsFileAttachment.txt&api-version=4.1
"User text content to upload"
Sample response
{
"id": "6b2266bf-a155-4582-a475-ca4da68193ef",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/6b2266bf-a155-4582-a475-ca4da68193ef?fileName=textAsFileAttachment.txt"
}
Definitions
AttachmentReference
Name | Type | Description |
---|---|---|
id |
string (uuid) |
|
url |
string |