coldfusion - 如何将 ReportCloud API 响应返回到可下载文件中?
问题描述
我正在使用 ColdFusion 调用ReportCloud API,它根据我通过 cfhttp 发送的参数即时合并邮件。
文档的回复说:
成功时,响应标头中的 HTTP 状态代码为 200(OK)。响应正文包含编码为 Base64 编码字符串的已创建文档数组。
有人可以帮助我如何将该响应转换为可下载文件,无论是链接还是直接下载?我可能应该知道这一点,但不幸的是我不知道。
添加评论:
感谢您对这个问题的帮助和指导。我第一次使用 StackOverflow 作为海报,如果问题含糊,我深表歉意。
我还整理了一个代码示例来查看cffiddle
<!--- Must replace "Authorization" header below with a real key --->
<cfset variables.jsonReq = '{
"mergeData": [
{
"Given_Name": "Mike",
"Surname": "Smith",
"Year_Group": "11"
},
{
"Given_Name": "Sally",
"Surname": "Smith",
"Year_Group": "12"
}
],
"template": null,
"mergeSettings": null
}'>
<cfhttp url="https://api.reporting.cloud/v1/document/merge?returnFormat=DOC&templateName=parentletter.docx" method="post" timeout="20" result="response" file="/www/something.docx">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="header" name="Authorization" value="ReportingCloud-APIKey oMDM4MrAqL9QEOpyzupnQW5NjvCNtvE5cVDaaLqxI">
<cfhttpparam type="body" name="mergeData" value="#jsonReq#">
</cfhttp>
<cfdump var="#response#">
响应以我认为是 JSON 数组的形式返回。我不确定如何读取该 JSON 数组并将内容制作成可下载的文件。
解决方案
推荐阅读
- r - R - 切换因子中的水平和值
- .net - UI 在填充 TreeView 时冻结
- python - 如何在 python 上导入 [spacy] .pos_
- javascript - 在大量代码中搜索对 jquery 版本文件的引用的正则表达式
- kubernetes - 在同一 k8s 租户中管理微服务和单体服务以供常用的 Istio 最佳实践
- r - R R6 使用 roxygen2 继承 - “命名空间:ParentPackage”不导出类“ParentClass”
- docker - 在 docker 中运行 Azure 管道任务
- terraform - 使用 for_each 创建模块时传递模块的输出
- python - 如何将超过 8 个参数传递给 ibm_db bind_param?
- c# - TCP 服务器连接导致处理器过载