title: How to download files using axios.post from webapi
body: <p>I have a complex object parameter that I need to send as post, as it could be too long for querystring. The post call is asking to have an excel file dynamically generated and then downloaded asynchronously. But all of this is happening inside of a react application. How does one do this using axios.post, react, and webapi? I have confirmed that the file does generate and the download up to the response does come back, but I'm not sure how to actually open the file. I have a hidden iframe that I'm trying to set the path, src, of the file to, but I dont know what response property to use.</p>
  
  <pre><code>// webapi
  [HttpPost]
  public HttpResponseMessage Post([FromBody]ExcelExportModel pModel)
  {
      var lFile = ProductDataModel.GetHoldingsExport(pModel);
      var lResult = new HttpResponseMessage(HttpStatusCode.OK);
      lResult.Content = new ByteArrayContent(lFile);
      lResult.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
      {
          FileName = "HoldingsGridExport.xls"
      };
  
      lResult.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
  
      return lResult;
  }
  
  // client side api
  static getHoldingsExport({ UserConfigurationID, UserID, Configurations, ViewName, SortModel, FilterModel, UserConfigType, IsDefault, LastPortfolioSearchID = null, ProductId }) {
      const filterModel = JSON.stringify(FilterModel); // saving as string as this model is dynamically generated by grid out of my control
      const sortModel = JSON.stringify(SortModel);
  
      let params = JSON.stringify({
          UserConfigurationID,
          UserID,
          Configurations,
          ViewName,
          filterModel,
          sortModel,
          UserConfigType,
          IsDefault,
          LastPortfolioSearchID,
          ProductId
      });
  
      return axiosInstance.post("/api/HoldingsExport", params);
  }
  
  // client side app call to get file
  HoldingsApi.getHoldingsExport(config)
      .then(function(response) {
          debugger;
          let test = response;
      })
      .catch(error =&gt; {
          toastr.success('Failed to get export.');
      });
  </code></pre>