Welcome to the Smartsheet Forum Archives


The posts in this forum are no longer monitored for accuracy and their content may no longer be current. If there's a discussion here that interests you and you'd like to find (or create) a more current version, please Visit the Current Forums.

ColdFusion and SmartSheet API

NoryB
NoryB
edited 12/09/19 in Archived 2016 Posts

 

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:

<span class="tag" style="border: 0px; color: #7d2727;"><cfscript></span><span class="pln" style="border: 0px; color: #303336;">
    apiURL = "https://api.smartsheet.com/2.0/sheets";
    apiToken = "xxxxxxxxxxxxxxxxxxxxxxxxx";
</span><span class="tag" style="border: 0px; color: #7d2727;"></cfscript></span><span class="tag" style="border: 0px; color: #7d2727;"><cfhttp</span><span class="atn" style="border: 0px; color: #e64320;">url</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"#apiURL#"</span><span class="atn" style="border: 0px; color: #e64320;">method</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"GET"</span><span class="atn" style="border: 0px; color: #e64320;">result</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"httpResp"</span><span class="atn" style="border: 0px; color: #e64320;">timeout</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"120"</span><span class="atn" style="border: 0px; color: #e64320;">charset</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"utf-8"</span><span class="tag" style="border: 0px; color: #7d2727;">></span><span class="tag" style="border: 0px; color: #7d2727;"><cfhttpparam</span><span class="atn" style="border: 0px; color: #e64320;">type</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"header"</span><span class="atn" style="border: 0px; color: #e64320;">name</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"Authorization"</span><span class="atn" style="border: 0px; color: #e64320;">value</span><span class="pun" style="border: 0px; color: #303336;">=</span><span class="atv" style="border: 0px; color: #0f74bd;">"Bearer #apiToken#"</span><span class="tag" style="border: 0px; color: #7d2727;">/></span><span class="tag" style="border: 0px; color: #7d2727;"></cfhttp></span>

However I do not receive the desired response: CFDump Image

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

SmartSheet API 2.0 Example Request:

<span class="pln" style="border: 0px; color: #303336;">curl https</span><span class="pun" style="border: 0px; color: #303336;">:</span><span class="com" style="border: 0px; color: #858c93;">//api.smartsheet.com/2.0/sheets -H "Authorization: Bearer ACCESS_TOKEN"</span>

Comments

  • dAVE Inden
    dAVE Inden Employee

    Have you tried making this request in terminal using cURL or in a REST client like Postman to see what the response looks like?

    What is the response that you get? Do you get any error messages?

    Looking at the image you linked to I did see at the top the APIURL is set to version 1.1 of the Smartsheet API, which is deprecated at this time, even though you look to be setting the apiURL value to be for version 2.0 of the API.

    I haven't worked in ColdFusion before so you might consider reaching out to their support to see if they can assist with any errors.

  • NoryB
    NoryB
    edited 12/02/16

    Hi Dave,

     

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

    Also converting the returned fileContent object into a string using:

     <cfset rawJSONString = httpResp.fileContent.toString()>  worked for me as well.

     

    Thanks for you help

  • dAVE Inden
    dAVE Inden Employee
    edited 12/02/16

    Glad to hear you got it working!

This discussion has been closed.