2

I'm implementing Office JS custom functions which make requests to an external API via POST. Currently I'm getting an error "Network Error" using the custom functions runtime on desktop.

This error only occurs when sending data (data config option with axios). When sending with data: undefined I get a successful post request. Fetch/XMLHttp give the same error. These post requests work fine on the excel web client.

The code in question is simply:

    return axios.post('api endpoint', {...data})
        .then(response =>{ 
            console.log(response)
        });

functions.html

    <script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/custom-functions-runtime.js" type="text/javascript"></script>

The error:

7/31/2019 8:38:59   Verbose Runtime [Console] [Log] Verbose CustomFunctions [Execution] [Begin] Function=IRR        
7/31/2019 8:38:59   Verbose Runtime [Console] [Log] Unexpected CustomFunctions [Execution] [End] [Failure] [RejectedPromise] Function=IRR Error: Network Error {"message":"Network Error","name":"Error","description":"Network Error","stack":"Error: Network Error\n   
at createError (C:\\Users\\{USER}\\AppData\\Local\\Microsoft\\Office\\16.0\\Wef\\{77465F27-AF7B-4EBF-B345-B511C35C4E42}\\vai+V16+KDygsa7v22t_6Q==\\Javascript\\fbcfcf48-d846-415b-9418-8278af45662f_1.0.0.0_en-US\\bundle.js:657:3)\n   
at handleError (C:\\Users\\{USER}\\AppData\\Local\\Microsoft\\Office\\16.0\\Wef\\{77465F27-AF7B-4EBF-B345-B511C35C4E42}\\vai+V16+KDygsa7v22t_6Q==\\Javascript\\fbcfcf48-d846-415b-9418-8278af45662f_1.0.0.0_en-US\\bundle.js:188:7)\n   
at dispatchEvent.value (foundation.win32.bundle:1:36516)\n   
at value (foundation.win32.bundle:1:111669)\n   
at value (foundation.win32.bundle:1:108416)\n   
at Anonymous function (foundation.win32.bundle:1:110776)\n   
at value (foundation.win32.bundle:1:61902)\n   
at value (foundation.win32.bundle:1:56068)\n   
at Anonymous function (foundation.win32.bundle:1:53578)\n   
at value (foundation.win32.bundle:1:55337)",
 "config":{
  "url":"{api endpoint}",
  "method":"post",
  "data":"{data i'm sending}",
  "headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"},
  "transformRequest":[null],
  "transformResponse":[null],
  "timeout":0,
  "xsrfCookieName":"XSRF-TOKEN",
  "xsrfHeaderName":"X-XSRF-TOKEN",
  "maxContentLength":-1}}       
7/31/2019 8:38:59   Unexpected  CustomFunctions [Execution] [Async] [End] [Failure] Function=IRR, Workbook=functionbug.xlsx     
phillipl
  • 21
  • 2

1 Answers1

0

this is likely because custom functions does not yet support Full CORS yet. Team is working on that and should have an update here soon:

https://github.com/OfficeDev/office-js/issues/523

  • Ah, wasn't sure if that was the case as it works fine on the web client. Thanks for the clarification and sitrep on the issue. – phillipl Aug 05 '19 at 11:32