Closed isfuku closed 3 years ago
Hi @isfuku,
In Metabase API docs for creating a card (link) it says:
"description
value may be nil, or if non-nil, value must be a non-blank string."
This seems to be the issue. I'll apply your suggestion, but note that description
is not a required argument, you can just leave it out when using the create_card
function with custom_json
.
This part of the create_card
function docs may be helpful as well.
BTW, when creating a card, you can set verbose=True
to print extra information.
@vvaezian thanks dor the reply. I encountered the issue when copying a card with no description, that instead of generating a custom_json
with null description
, generated one with a blank string for description
.
That is really weird, because the copy_card
function doesn't change the description
.
Please go the the card that produced the error when copying, get its ID (in the address bar, at the end: https://.../question/[card_id]), then run the following command, and let me know what you see as the value for the description
key
mb.get('/api/card/[card_id]')
Please also provide the error message which you get when copying the card.
mb.get('/api/card/[card_id]')
returns 'description': ''
, and copy_card
returns the error menssage Card Creation Failed.
and res = False
.
To circumvent the problem, I edited the create_card
function, adding the conditional statement
if custom_json['description'] == '': custom_json['description'] = None
I see. So the description
in the original card was not None
, but the empty string. This is still weird as how it was possible that empty string got set as the description of that card.
Anyways, I'll apply your suggestion in the code which would fix this rare situation.
Fixed in v0.2.8.
Copying a card or creating a card using custom_json with description = '' results in an non-informative error. My sugestion is to either add an informative error mensage, or to create a conditional statement such as "if custom_json['description'] = '' then custom_json['description']= None".