Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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

        //Get the stream from the content URL
        getStreamData(screenshot.src).then(function (streamData) {

            //Get the blob data from the stream
            streamData.blob().then(function (blob) {

                //upload the attachment 
                uploadAttachment(blob, fileName).then(function (res) {
                    console.log("Attachment uploaded successfully: ", res);

                    //Update work item with attachment link
                    linkAttachmentToWorkitem(res.url, <workItemID>);
                });
            });
        });

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

processData: false

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda