0

I got a tip from a previous question for getting a list of column names in a Carto table.

I enter this into my browser: https://MY_CARTO_USERNAME.carto.com/api/v2/sql?q‌​=SELECT column_name FROM information_schema.columns WHERE table_schema = 'MY_CARTO_USERNAME' AND table_name = 'TABLE_NAME'&api_key=MY_API_KEY. Of course, I replace MY_CARTO_USERNAME and MY_API_KEY with my Carto username and API key.

This is the error I get: {"error":["You must indicate a sql query"]}

What must I change in my query to get the column names of my Carto table?

2

Try to replace the white spaces with +. I think this is the cause of your problem. Also, table_schema is not needed. This query works for me:

https://USER_NAME.carto.com/api/v2/sql?q=SELECT+column_name+FROM+information_schema.columns+WHERE+table_name+=+'TABLE_NAME'&api_key=API_KEY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.