Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!