Curl GET request mixed results

Mike Dahl
Mike Dahl ✭✭✭
edited 12/09/19 in API & Developers

Hello community,

Just getting started and trying to leverage Curl to proof a few things out. When I issue the following example command, I get a list of my sheets successfully:

curl -X GET -H "Authorization: Bearer " "https://api.smartsheet.com/2.0/sheets"

When I issue a more specific command listing one of the sheet ID's returned in the above results:

curl -X GET -H "Authorization: Bearer XXXXXXXXXXXX" "https://api.smartsheet.com/2.0/sheets/6141831453927300"

I get the following error:

{

  "errorCode" : 1004,

  "message" : "You are not authorized to perform this action.",

  "refId" : "1w34sp5pw1k00"

}

I was trying to add a column to a sheet I owned and it gave me the same error, so I started with the simplest command and built upon it to find out when this error occurred. Hopefully it is something simple I am missing.

Many thanks in advance.

-Mike

Comments

  • Hi Mike,

    Looks like the endpoint you're using to add columns is this:

    https://api.smartsheet.com/2.0/sheets/{sheetId}

    The endpoint for add column is: https://api.smartsheet.com/2.0/sheets/{sheetId}/columns

    Try adding the /columns to your endpoint in your request. If that doesn't work, make absolutely sure that your auth token is coming from your account. (You might generate a new token to test.) Also make sure that the sheet Id is a sheet that you own or have Admin permissions on (assuming you have a license).

    You can use the API to check your sharing permissions level on the ID you're trying to call: https://smartsheet-platform.github.io/api-docs/?shell#get-sheet-share

    More info on the add columns cURL request can be found here: https://smartsheet-platform.github.io/api-docs/?shell#add-columns

  • Mike Dahl
    Mike Dahl ✭✭✭

    Thanks for looking into this Shaine. I am still getting the permission issue. I am the owner, but it let me qury the sheet without issue and id sees that I am the owner. I tried creating a new workspace and moving it into there and same result. I also tried accessing another sheet where I just have Admin and still the same error. As a last effort, I replaced my token and tried again. Still get the permissions error.

    -Mike

  • Mike a few things to confirm here:

    • Confirm that you're using the /columns with your endpoint.



      Your original code just has /sheets/<sheet id>



      It needs the /columns if you're going to try and add a column.

       
    • Also make sure that you're not performing a GET request when trying to add a column. Adding a column is a POST request, so you'll want to use -X POST instead of -X GET

       
    • Please also confirm that you're generating an API token from the same account that owns the sheet.

    If the above doesn't work, try this:

    1. Create a brand new sheet
    2. Get the sheet ID of that new sheet
    3. Try performing the same requests with your code

    Otherwise, if you're still experiencing issues—reach out to our Support team and they can further assist.