Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
How can I POST data in Excel custom functions add-in?

I have generated an Office Add-In for Excel using the Yo Office Generator.

From that add-in, I would like to call a RESTful API.

GET requests work as expected using fetch, but I am trying to implement the batched query pattern provided by Microsoft. I expect the query string to be too long to use the GET method for a typical batch. I want to use the POST method so that I can have many different objects in the API request body.

My actual use case (simplified here) is to return results for a batch of calculations, performed on the server.

I have the following custom function, posting to an online test API:

/**
 * Test Post Method
 * @customfunction
 * @returns {string}
 */
async function PostTest() {
  try {
      const url = 'https://reqbin.com/sample/post/json';
      const response = await fetch(url,  {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({'key':'value'})
      });
      if (!response.ok) {
        throw new Error(response.statusText)
      }
        const jsonResponse = await response.json();
        
        return jsonResponse;
    }
    catch (error) {
      return error.name + ' ' + error.message
    }
}

The fetch call fails with: TypeError Network request failed

I have read the issues with CORS mentioned on this site, especially this one. I think that CORS wouldn't be an issue with the resource that I am accessing. I have enabled shared run time. I need this to work on Excel Desktop client.

Thank you in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda