how to create Attachment of WorkItem Tracking in a postman

SIVARANJANI VASUDEVAN 1 Reputation point
2022-10-29T10:13:31.207+00:00

https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?view=azure-devops-rest-5.1&tabs=HTTP#upload-a-binary-file

i want to create an attachment

255323-image.png

but not properly getting upload. could you please share how to hit create attachment api

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,002 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruno Lucas 4,421 Reputation points MVP
    2022-10-30T05:44:42.277+00:00

    Hi @SIVARANJANI VASUDEVAN

    You first need to plan for authentication. you can use oauth or login into devops and generate a PAT token: https://docs.searchunify.com/Content/Content-Sources/Azure-Generate-Personal-Access-Token.htm

    This is how you use in Postman: https://www.sanderh.dev/call-Azure-DevOps-REST-API-Postman/

    to upload to a work item you need two operations/apis

    First the one on the link you posted:

    255270-image.png

    POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=imageAsFileAttachment.png&api-version=5.1

    that will upload the attachment to devops and return a url. with that url you can finally attach to the work item using this second api: https://dev.azure.com/fabrikam/_apis/wit/workitems/2?api-version=5.0

    more here: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-server-rest-5.0&tabs=HTTP#add-an-attachment

    255388-image.png

    some more info: https://stackoverflow.com/questions/66101212/ado-upload-an-attachment-to-azure-devops-via-http-rest-request

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments