NoryB NoryB - 1 year ago 111
JSON Question

ColdFusion and SmartSheet API

I'm attempting to call the api and read the JSON data from a list sheet request. Im new to API's so I'm certain I'm missing much with my code.

Here is what I have so far:

apiURL = "";
apiToken = "xxxxxxxxxxxxxxxxxxxxxxxxx";

<cfhttp url="#apiURL#" method="GET" result="httpResp" timeout="120" charset="utf-8">
<cfhttpparam type="header" name="Authorization" value="Bearer #apiToken#" />

However I do not receive the desired response:


I was attempting to use the sample provided to retrieve the data:

SmartSheet API 2.0
Example Request:

curl -H "Authorization: Bearer ACCESS_TOKEN"

Example Response:

"name":"sheet 1",
"name":"sheet 2",

Answer Source

What version of CF? Looks similar to this issue: ColdFusion 9.0.1 - 3574332 CHTTP returns filecontent as when mimetype is application/json. The workaround is to either:

  • Set the CFHTTP attribute getasbinary="never" OR
  • Convert the returned fileContent object into a string using:

     <cfset rawJSONString = httpResp.fileContent.toString()>   
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download