coldfusion - 奇怪的 ColdFusion cfscript 语法问题
问题描述
我的 cfscript 中有一个非常奇怪的语法错误。
stFields = {
"EligibilityQuery": {
"Patient": {
"FirstName": arguments.data.lname,
"MiddleName": "",
"LastName": arguments.data.fname,
"DateOfBirth": dateformat(arguments.data.dob,'yyyy-mm-dd'),
"Gender": arguments.data.gender,
"SSN": arguments.data.SSN,
"Address": {
"FirstLine": "",
"SecondLine": "",
"ZipCode": arguments.data.ZipCode
}
},
"NPI": "1111111"
}
};
// call API
var authorization = "Basic: " & ToBase64('username:password');
cfhttp(method="POST", url="https://mysite/api/myAPI/", result="apiResult"){
cfhttpparam(name="Authorization", type="header", value="#authorization#");
cfhttpparam(name="Content-Type", type="header", value="application/json");
cfhttpparam(type="body", value="#serializeJSON(stFields)#");
}
apiResult = deserializeJSON(apiResult.fileContent);
它在 cfhttp 上返回错误(脚本语句必须以“;”结尾。)
错误 - CFML 编译器正在处理:
cfhttp(method="POST", url="https://mysite/api/myAPI/", result="apiResult")
我在哪里错过了“;”?
解决方案
期待;
之后cfhttp(method="POST", url="https://mysite/api/myAPI/", result="apiResult")
。
你是CF9还是CF10?尝试这个:
// call API
var authorization = "Basic: " & ToBase64('username:password');
httpService = new http(method = "POST", charset = "utf-8", url = "https://mysite/api/myAPI/");
httpService.addParam(name = "Authorization", type = "header", value = "#authorization#");
httpService.addParam(name = "Content-Type", type = "header", value = "application/json");
httpService.addParam(type = "body", value = "#serializeJSON(stFields)#");
apiResult = httpService.send().getPrefix();
apiResult = deserializeJSON(apiResult.fileContent);
推荐阅读
- powershell - 当 IE 安全级别区域为高时,Connect-PnPOnline -UseWebLogin 登录弹出窗口不加载
- c - 如何使用 SSE 检查字符串是否包含一些字母
- json - 可以在 json.dump 中使用 open inline
- javascript - MaterialUI -withStyles 特殊原因
- javascript - Typescript React:使用传递给同一组件的另一个道具有条件地将道具标记为可选或强制
- javascript - 除了 IE,代码在任何地方都运行良好,不知道为什么
- php - 使用 docker 在 laravel 上的 Nginx 子目录给出 404
- python - 我可以触发并忘记提交到线程池的可调用对象吗?
- r - 使用 ggplot2 和 purrr 创建密度图;基于组的密度线颜色
- c# - 试图在我的程序中获取 .settings 文件