0

Background: I am using cfhttp and an auth token provided to me by a vendors API to do two GET calls. The first one fails the second is successful.

Call #1 is supposed to return a list of Order ID's in JSON format. Call #2 uses one of those Order ID's to return a full order again in JSON format.

The calls are outlined below:

Request all of the ORDER ID's

<cfhttp method="get" url="https://test-9832.APIURL.com/criminal_api//1.0/service/requests" result="orderFirst">
    <cfhttpparam type="Header" name="Authorization"  value="Bearer 5BDCECFBDBE4680E74C8B81A58EAC544"> 
</cfhttp>

Request a full order based on the same auth token and one of the Order Ids returned in the previous step:

<cfhttp method="get" url="https://test-9832.APIURL.com/criminal_api//1.0/service/requests/WB-042916-YH59Z-PL-001" result="orderFull">
    <cfhttpparam type="Header" name="Authorization"  value="Bearer 5BDCECFBDBE4680E74C8B81A58EAC544"> 
</cfhttp>

The calls are using the same exact cfhttpparam and value the only difference is the URL. The vendor mentioned they sometimes see issues if the Auth Token is double encoded. I am setting the auth token value statically at this point just to get it to work.

Below is a cfdump of what is returned in Step #1 that fails:

struct
Charset     UTF-8
ErrorDetail     [empty string]
Filecontent     Connection Failure
Header  HTTP/1.1 200 OK Connection: close Expires: Wed, 31 Dec 1969 16:00:00 PST Date: Wed, 14 Sep 2016 04:47:01 GMT Server: hws Pragma: No-cache Cache-Control: no-cache Set-Cookie: X-HR-ClientSessionId=2_12.161.115.226_1473828421271;Secure; path=/; HttpOnly Content-Type: application/json;charset=UTF-8
Mimetype    application/json
Responseheader  
struct
Cache-Control   no-cache
Connection  close
Content-Type    application/json;charset=UTF-8
Date    Wed, 14 Sep 2016 04:47:01 GMT
Expires     Wed, 31 Dec 1969 16:00:00 PST
Explanation     OK
Http_Version    HTTP/1.1
Pragma  No-cache
Server  hws
Set-Cookie  X-HR-ClientSessionId=2_12.161.115.226_1473828421271;Secure; path=/; HttpOnly
Status_Code     200
Statuscode  200 OK
Text    NO 

The status code is showing 200 OK but the file contents is Connection Failure.

QUESTION: Is there anything else I can add to my script to help debug or test?

Denoteone
  • 3,875
  • 21
  • 88
  • 138
  • are you sure the url is correct https://test-9832.APIURL.com/criminal_api//1.0/service/requests/WB-042916-YH59Z-PL-001 There appear to be 2 slashes after criminal_api – William Greenly Sep 14 '16 at 08:08
  • 1
    Which version of ColdFusion are you on? It could be a cert issue. This may help http://stackoverflow.com/questions/20469194/coldfusion-https-connection-failure – John Whish Sep 14 '16 at 13:03
  • If you are expecting text (JSON), consider adding getasbinary="never" or ColdFusion will guess at the return type. This has resulted in filecontent issues for us in the past. (Also remove the double slash in the URL.) – James Moberg Sep 14 '16 at 13:23
  • The `Connection Failure` is the actual content delivered by the target endpoint, it even returns `200 OK`. So this is not a connection problem on the HTTP client's side (`cfhttp`), but an issue with the endpoint. Check the documentation or contact the API provider for details. – Alex Sep 14 '16 at 22:44

0 Answers0