Downloading Excel File in Appian using Web API.

Certified Senior Developer

Hi All,

I have a requirement to download the data into excel using web api in Appian. Data is coming from external API.

Using web api, I am able to dowload .csv and.xls file. But To download the .xlsx file. Is there any way.

Currently I am writing the sample code like below.

a!localVariables(
local!data:{
{name:"A",age:10},
{name:"A",age:10}

},

a!httpResponse(

headers: {
a!httpHeader(
name: "Content-Type",
value: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
),
a!httpHeader(
name: "Content-Disposition",
value: "attachment; filename= test.xlsx"
)
},

body:local!data
)

)

whenever i tried to open the file. Below is the error. Can you please tell how can we resolve this issue?

Thanks in Advance!!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You might look into the "JSON to Excel Smart Service Convertor" plug-in, and calling this in a process model from your API.  I'm not 100% clear whether it will work within your required use case, but it is able at least to generate valid .XLSX files from arbitrary input dictionary data.

    Edit: actually if your data is coming from an external API, it seems to me like you can probably just pass this data into a process model containing this node, without needing to call an Appian API.  Some more details about your requirements might help solidify a suggested approach though.

Reply
  • 0
    Certified Lead Developer

    You might look into the "JSON to Excel Smart Service Convertor" plug-in, and calling this in a process model from your API.  I'm not 100% clear whether it will work within your required use case, but it is able at least to generate valid .XLSX files from arbitrary input dictionary data.

    Edit: actually if your data is coming from an external API, it seems to me like you can probably just pass this data into a process model containing this node, without needing to call an Appian API.  Some more details about your requirements might help solidify a suggested approach though.

Children