Skip to content
Advertisement

Uploading an attachment to Azure DevOps Server using Rest API from a JavaScript application

I’m looking for an example on how to generate the request body when uploading an attachment to Azure DevOps Server. Looking at the documentation here, it notes the content for the body should be “[BINARY FILE CONTENT]”. The content of the body is coming from a URL (https://someURL/images/abc.png for example). How do I get from fetch(url) -> binary content to put in the POST request to create the attachment?

Advertisement

Answer

Found a solution that works. For reference here’s the code:

JavaScript

The key to all of this, for me anyway, was adding

JavaScript

to the ajax settings, for the POST request, in the uploadAttachment function.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement