## 2025 - Azure DevOps workitem attachments need to first be made with [POST request](https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?view=azure-devops-rest-7.2&tabs=HTTP) - then once they exist you add the link reference to the object to the work item via a [workitem patch](https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-7.2&tabs=HTTP#add-an-attachment) and the body looks like this: ```json [ { "op": "add", "path": "/relations/-", "value": { "rel": "AttachedFile", "url": "https://azure-devops.com/00723e02-0000-4947-9999-cc73db66e00d/_apis/wit/attachments/1f999dea-6666-40e0-bbbb-7adbd576fccc?fileName=sample.txt", "attributes": { "comment": "my comment" } } } ] ``` - learned what was wrong with getting SNOW attachments, the endpoint was wrong (rookie move) its really this endpoint to get them: - https://instance.servicenowservices.com/api/now/attachment?sysparm_query=table_sys_id=562047c6870b62900001b848cebb3550 - Where the table_sys_id is the ID of the Incident itself. This GET request returns metadata on the attachments ON that Incident - Then you take the result `sys_id` which is the ID of the actual attachment and then you can the raw file download link via: - https://instance.servicenowservices.com/api/now/attachment/0f095d3787c72e90f511b8480000358e/file - which will straight up download the file - learned that i can get specific ADO work items i want with the wiql endpoint which basically lets me run SQL queries against the work items and then i can select the field and value i want from it and use that in other REST requests. - Namely, you can use this to query the values held in custom fields so you can then get the ID of a specific workitem and then do more things to it rather than hunting and pecking for a reference. ```json { "query": "Select [Custom.ServiceNowID] From WorkItems Where [System.TeamProject] = 'ServiceNow' AND [Custom.ServiceNowID] = 'INC0020769'" } ```