I’ve a question, I automate so many tasks using the CLI tool
az boards work-item relation show
az boards work-item show
az boards work-item update
But now, my doubt is, as part of my automation, I need to upload an attachment to some workitems, is possible do that using the CLI?
Searching I found this link:
https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?view=azure-devops-rest-7.0&tabs=HTTP#upload-a-text-file
But I do not see where specify the workitem ID where you want to upload the file, somebody face by this need?
Thank you, best regards.
2
Answers
Thank you very much, it's works, your guide it's perfect and very clear. Just last question. I see that when generate the content, it's convert to oneline text, the result of multiline file is this:
Note the start and finish character " and the addition of character n, this is my code to add the upload.
By other side I tried to upload a binary method:
https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/attachments/create?tabs=HTTP#upload-a-binary-file
And when upload the result is this:
How can I do to keep the format and not be treated as string all the content?
Thank you again.
Yes, you can upload the attachment in a specific work item in two steps-
First Create the attachment file using below URL
Here Request Body is
"User text content to upload"
Second add this attachment to a specific work item using below URL
Request Body-
Use the above generated URL in below request body
In this way, you can upload an attachment to a work item.
You can refer to this SO-Thread and MS docs as well.