Question

I am trying to mimic this curl request with ColdFusion cfhttp from this sample here:

https://docs.fatzebra.com.au/purchases

In a linux terminall the curl request works perfectly

<cfset origTemp = ' 
    \{ \
    \"card_holder\": \"Jim Smith\", \
    \"card_number\": \"5123456789012346\", \
    \"card_expiry\": \"05/2014\", \
    \"cvv\": \"987\", \
    \"amount\": 1000, \
    \"reference\": \"zzzzsORD98976\", \
    \"customer_ip\": \"111.222.111.123\" \
}'/>

<cfset tmp = {} />
<cfset tmp['card_holder'] = "Jim Smith" />
<cfset tmp['card_number'] = '512345678901234a6' />
<cfset tmp['card_expiry'] = '05/2013' />
<cfset tmp['cvv'] = '987z' />
<cfset tmp['amount'] = 'a1000' />
<cfset tmp['reference'] = 'ORD98976' />  
<cfset tmp['customer_ip'] = '111.222.111.123' />

<cfhttp url='https://gateway.sandbox.fatzebra.com.au/v1.0/purchases' useragent="#cgi.http_user_agent#" username="Test" password="Test" result="r" method="post" >
<cfhttpparam type="header" name="content-type" value="application/json" />
<!---<cfhttpparam type="body" value="#origTemp#" />--->
<cfhttpparam type="body" value="#serializeJson(tmp)#" />
</cfhttp>

<cfdump var="#r#" />

Without any luck.

Was it helpful?

Solution

The cUrl call is using login: TEST, password: TEST. Your code is using login: Test, password: Test. Those are two different sets of credentials, and the error you're getting suggests that's the issue.

(disclosure: CFJones & I worked through this offline, and this was the answer we arrived at)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top