Skip to main content
Participant
Nov 29, 2016 1:14 AM UTC
Question

ColdFusion and SmartSheet API

I'm attempting to call the smartsheet.com 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:

<cfscript>

    apiURL = "https://api.smartsheet.com/2.0/sheets";

    apiToken = "xxxxxxxxxxxxxxxxxxxxxxxxx";

</cfscript>

<cfhttp url="#apiURL#" method="GET"  result="httpResp" timeout="120" charset="utf-8">

    <cfhttpparam type="header" name="Authorization" value="Bearer #apiToken#" />

</cfhttp>

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 https://api.smartsheet.com/2.0/sheets -H "Authorization: Bearer ACCESS_TOKEN"

Example Response:

{ 

   "pageNumber":1,

   "pageSize":100,

   "totalPages":1,

   "totalCount":2,

   "data":[ 

      { 

         "accessLevel":"OWNER",

         "id":4583173393803140,

         "name":"sheet 1",

         "createdAt":"2015-06-05T20:05:29Z",

         "modifiedAt":"2015-06-05T20:05:43Z"

      },

      { 

         "accessLevel":"OWNER",

         "id":2331373580117892,

         "name":"sheet 2",

         "createdAt":"2015-06-05T20:05:29Z",

         "modifiedAt":"2015-06-05T20:05:43Z"

      }

   ]

}

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

WolfShade
Legend
Dec 1, 2016 5:17 PM UTC

Hello, Bygra​,

Upon reading your post, the first thing that confuses me is that you state you are accessing 2.0 and your code shows 2.0, but the response back says the URL is 1.1.

Another thing that confuses me is that the response is 200 (OK), and it's trying to hand you a binary (file).

Now, I am not at all familiar with smartsheet, have zero clue what that is.  But it appears that the response is good and it's sending back either a file, or some kind of struct that contains a file.

Have you read and understood the smartsheet API documentation?  Does it state specifically what the API is sending back on successful connections?

HTH,

^_^

Translate
BygraAuthor
Participant
Dec 2, 2016 2:37 PM UTC

Hi Wolfshade,

I got it working by setting the CFHTTP attribute getasbinary="never".

also converting the returned fileContent object into a string using:

<cfset rawJSONString = httpResp.fileContent.toString()>  

worked for me too.

Thanks for you help

Translate
BKBK
Community Expert
Community Expert
Dec 4, 2016 9:35 AM UTC

@Bygra, please mark your answer as correct. It will help someone with a similar problem.

Translate