Coldfusion-10中的cURL(cfhttp)命令有效,但是将相同的代码迁移到Coldfusion-2018后不起作用。
我在CF10上使用了以下代码。
<cfset
structContainer = {
"container": {
"number": "ABCD123456",
"shipping_line": "ABCD",
"sandbox_url": "http://api.myhost.com/"
}
}/>
<cfset structJson = serializeJSON(structContainer) />
<cfhttp
url="https://customerurl/api/v1/"
method="post"
result="structResult"
username="myaccount@myhost.com"
password="12345">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="header" name="Authorization" value="Token token=x1x2x3x4x5x6">
<cfhttpparam type="header" name="X-ApiVersion" value="1.0">
<cfhttpparam type="header" name="Accept" value="*/*">
<cfhttpparam type="body" encoded="false" value="#trim(structJson)#">
</cfhttp>
<html>
<body>
<cfoutput>
<cfdump
var="#structResult#"
label="HTTP Body"
output="c:/result.txt"
/>
</cfoutput>
</body>
</html>
但是当我迁移到Coldfusion 2018时,返回以下错误(structResult):
HTTP Body - struct
Charset: utf-8
Errordetail: [empty string]
Filecontent: HTTP Token: Access denied.
Header: HTTP/1.1 401 Unauthorized
Date: Mon, 21 Oct 2019 12:56:48 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
WWW-Authenticate: Token realm="Application"
Cache-Control: no-cache
X-Request-Id: 4539026e-8b8d-4f67-836b-153b8b9c58fc
X-Runtime: 0.006391
Strict-Transport-Security: max-age=31536000
Mimetype: text/html
Responseheader:
[struct]
Cache-Control: no-cache
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Mon, 21 Oct 2019 12:56:48 GMT
Explanation: Unauthorized
Http_Version: HTTP/1.1
Status_Code: 401
Strict-Transport-Security: max-age=31536000
Transfer-Encoding: chunked
WWW-Authenticate: Token realm="Application"
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 4539026e-8b8d-4f67-836b-153b8b9c58fc
X-Runtime: 0.006391
X-XSS-Protection: 1; mode=block
Statuscode: 401 Unauthorized
Text: YES
请,有人给我个灯吗?
最好的问候!