Knowledge Drop

AssertionError in SDK call

Userlevel 5

Last tested: Apr 30, 2020

Users of the SDK have seen this error in the past when using a dictionary syntax rather that using the WriteUser type in the body


import looker_sdk
from looker_sdk import models

new_friend = sdk.update_user(user_id=#, body=models.WriteUser(first_name="first_name_test",last_name="last_name_test"))



import looker_sdk

new_friend =

updated_user = sdk.update_user(user_id = #, body = {"User":{
"first_name" : "first_name_test",
"last_name" : "last_name_test",
"group_ids" : "[#]"}} )

print("updated_user: " + updated_user)



Does that mean when we reference the body we should always put a 'Write' in front of the call?

Explanation that we could share with the customer:

We have model objects (or classes) that we pass args into and Looker does the formatting for us. Our team is currently working on making the body parameters a bit more friendly, but right now, we recommend passing them into the model classes/objects and let the SDK do the work.

We can call model classes with models.NAME the same way we call an SDK method with sdk.NAME.

"Write" is a category of these model classes/objects. This doc lists out all model objects/classes. You'll see that they generally start with "Write" (but not always!)

In the past, we used to allow Dictionary syntax because Python is loose with typing. So a user could create an on-the-fly dictionary with the necessary parameters, though these didn't work all the time. But now, we have tightened up what is accepted in a call to actually be the correct type. So now we must call "writeUser" or whatever equivalent to get an actual object of the correct type to pass in to an API call.


This content is subject to limited support.                



0 replies

Be the first to reply!