• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ColdFusion and SmartSheet API

New Here ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

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:

SmartSheet.JPG

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"

      }

   ]

}

Views

610

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

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,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2016 Dec 04, 2016

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation