Smartsheet api call in python.

Options

Hi im trying to use the smart sheet API in Python with the following code.

#Establishes a connection to smart = smartsheet.Smartsheet(api_base="https://api.smartsheet.eu/2.0/sheets", access_token="MYTOKEN")

smart.assume_user("MYEMAIL")

#Establishes link to the time off requests

smartsheetsheet_id = "MYSHEETID"

sheet = smart.Sheets.get_sheet(sheet_id)  print(sheet)

But I am receiving the following error.

{"response": {"statusCode": 401, "reason": "Unauthorized", "content": {"errorCode": 1030, "message": "You are unable to assume the user specified.", "refId": "knzehm"}}}
{"result": {"code": 1030, "errorCode": 1030, "message": "You are unable to assume the user specified.", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ", "refId": "knzehm", "shouldRetry": false, "statusCode": 401}}

Is this possibly due to our organisation using single sign on? In any event any help you could provide would be appreciated.

Best Answer

  • Kezanub
    Kezanub
    Answer ✓
    Options

    Hi Genevieve,

    I have since fixed this issue. It was a combination of the code being wrong and my account not being set up as a Developer on the EU environment the first one was fixed with the below code change.

    smart = smartsheet.Smartsheet(api_base="https://api.smartsheet.eu/2.0/", access_token="MYAPIKEY")

    sheet_id = "MYSHEETID"
    sheet = smart.Sheets.get_sheet(sheet_id)

    and the second one was just a simple request to the staff at Smartsheet, hope this can help other developers.

Answers