Add new option to "Single select" field when creating new row via API

Hello,
Apologies if this has already been addressed. I’m trying to create a new row in a Baserow table in my self-hosted instance via the REST API. I keep getting an error when I try to use a new value for a “Select” dropdown field. It appears that if it isn’t in the existing list of options for that dropdown, the API will return an error.

Some info on the error I’m getting:

  • “ERROR_REQUEST_BODY_VALIDATION” - “The provided select option value ‘sample new value’ is not a valid select option.”

Is there a way to dynamically add new options to that Single select field as rows are being created?

Thanks in advance!

As far as I’m aware this can’t be done directly with the create/update row queries.

You could do a separate query first to update the field with the missing options using this endpoint: https://api.baserow.io/api/redoc/#tag/Database-table-fields/operation/update_database_table_field

2 Likes

Ah okay that makes sense.

I guess I’ll do some sort of check to see if that select option exists, if not add it via that endpoint, then continue on with creating a new row.

Thanks for your help!

Quick note for anyone who also wants to do this for a “select_option” field: you need to include the full array of options, then push your new value to that array, then take that modified array with everything and use that in your PATCH request.

I tried sending a PATCH of the new value I wanted to add and it wiped all of the previous options I had for that field and replaced it with the pnly single option value I was trying to add.

Hope this helps!

1 Like