获得基本身份验证以使用 ColdFusion [英] Getting Basic Authentication to work with ColdFusion

查看:31
本文介绍了获得基本身份验证以使用 ColdFusion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to send an authenticated POST request using ColdFusion, but for some reason, the server is rejecting the request as unauthorized. I have verified that the credentials are correct.

<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 中也有同样的效果.比如

Same thing works in curl. For instance

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 代码中缺少什么.

The above curl command return HTTP 200 which is what I am trying to achieve. I am unable to figure out what I am missing in the ColdFusion code.

推荐答案

以下确实有效.请考虑这个答案:

The following actually worked. Please consider this answered:

<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>

这篇关于获得基本身份验证以使用 ColdFusion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆