http - 获取基本身份验证以与 ColdFusion 一起使用

标签 http coldfusion basic-authentication

我正在尝试使用 ColdFusion 发送经过身份验证的 POST 请求,但由于某种原因,服务器拒绝了未经授权的请求。我已验证凭据是正确的。

<cfhttp url="https://api.juspay.in/order/create" method="POST"  
    username="320EABE1225D45E6B13DF5D3D2BBDB80" password="">
    <cfhttpparam name="amount" type="formField" value="10">
    <cfhttpparam name="order_id" type="formField" value="cfhttp_test_order_001">
    <cfhttpparam name="customer_id" type="formField" value="10">
    <cfhttpparam name="customer_email" type="formField" value="user@mail.com">
    <cfhttpparam name="customer_phone" type="formField" value="1122112211">
    <cfhttpparam name="description" type="formField" value="test">
</cfhttp>

同样的事情适用于 curl。例如

curl https://api.juspay.in/order/create \
    -u 320EABE1225D45E6B13DF5D3D2BBDB80: \
    -d "amount=10" \
    -d "order_id=curl_test_order_001" \
    -d "customer_id=10" \
    -d "customer_email=user@mail.com" \
    -d "customer_phone=1122112211" \
    -d "description=test" 

上面的 curl 命令返回 HTTP 200,这是我想要实现的。我无法弄清楚 ColdFusion 代码中缺少什么。

最佳答案

以下确实有效。请考虑这个回答:

<cfhttp method="post" url="https://api.juspay.in/order/create" result="result">
    <cfhttpparam type="header" name="Authorization" value="Basic #ToBase64("320EABE1225D45E6B13DF5D3D2BBDB80:")#" />
    <cfhttpparam type="formfield" name="amount" value="10" />
</cfhttp>

关于http - 获取基本身份验证以与 ColdFusion 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24933746/

相关文章:

c# - NASA Asterank 请求每次返回相同

sql - CFML & SQL - 性能提升?

sql-server - sum COALESCE 0 而不是 null

basic-authentication - 使用 Cro 的 perl6 中的基本身份验证

http - 为什么命令行计算的 base64 字符串与 curl 计算的 base64 字符串不同?

c++ - 重用 Asio 连接

http - 我可以让 httpOnly cookie 与 vue-resource 一起使用吗?

HTTP 重定向 (302) 在以下 GET 请求中不使用 Cookie

xml - jaxb 或 Coldfusion 的等价物

java - 如何获得在 WebSphere 上运行的基本身份验证?