Changing order of the fields using baserow api

Hi all,
I’ve been fiddling more with the API and I am struggling with changing the order of the fields.

I would appreciate any support.I see a bunch of ids like these when I list the fields :slight_smile:

{'field_options': {'4566': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4567': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4568': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4569': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4570': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4571': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4572': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4573': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200},
                   '4574': {'aggregation_raw_type': '',
                            'aggregation_type': '',
                            'hidden': False,
                            'order': 32767,
                            'width': 200}}

but how do I re-arrange my table columns? For example,I need name column to be 1st and the age column right next to it.

Is there a way to do this using the create_table_field instead of fiddling with the views?
Any help appreciated. Thank you so much in advance

Fields can have different orders in different views, so the view is the parent that cares about the ordering of the fields.

The field options you posted contain ids of the fields, and you can see the order property there. You should be able to call patch endpoint to change it.

When you reorder the fields in the UI you can observe the backend requests in browser development tools, and just modify it for your purpose.

but i am unable to identify the fields by name. these ids make no sense to me because they’re random ids. I cant use this without knowing the name of the fields. Is there a way to make this API display the name of the field or is there an alternative way?

Thanks

You can make an API call to

https://api.baserow.io/api/database/fields/table/{id of the table}/

This will return a list of fields including their id and name. You can find the entire API documentation at Baserow API spec.

okay, so i need to call the table/fields api and then the views API and then map them based on their ids first?

Thanks

Exactly @computersrmyfriends, but if you’re working on different views of the same table, you don’t need this extra step since the underlying fields are the same.