3 Replies Latest reply on Dec 4, 2016 1:35 AM by BKBK

    ColdFusion and SmartSheet API

    Bygra

      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"

            }

         ]

      }

        • 1. Re: ColdFusion and SmartSheet API
          WolfShade Level 4

          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,

           

          ^_^

          • 2. Re: ColdFusion and SmartSheet API
            Bygra Level 1

            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

            • 3. Re: ColdFusion and SmartSheet API
              BKBK Adobe Community Professional & MVP

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