Apr 04, 2017 07:47 PM
Hi I’m trying to use the airtable ruby gem and have run into a problem. If the table name contains spaces I cannot retrieve or add records. If I use a table name without spaces it works. I tried replacing the space with %20 but it didn’t help.
require 'airtable’
require ‘active_support/all’
client = Airtable::Client.new(“API_KEY”)
table = client.table(“APP_ID”, “‘Test Table’”)
records = table.records
print “#{records.count} records found\n"
record = Airtable::Record.new(“Creation Date” => Date.today.to_s, “Name” => “P-Town Giants”, “Email” => "ptown@gmail.com”, “Type” => “Team”)
res = table.create(record)
print res unless res
UPDATE: I’ve found the problem. the worksheet_url protected method in table.rb uses CGI::escape to escape “special” characters. Problem is it replaces space characters with ‘+’ where is should be replaced with %20 for the URL path.
I’ve opened an issue in github.
Jun 26, 2023 11:16 PM
Hey @Jonathan_Stockl
When utilizing table names with spaces, the Airtable Ruby gem in a ruby app appears to be giving you problems. You noted that adding '%20' in place of the room wasn't helpful either.
Your code suggests that you have initialized the Airtable client and table objects appropriately. The way you send the table name to the 'client.table' function may need to be changed, though.
Try using 'Test Table' instead of '"'Test Table'"' without any other quotes or special characters:
table = client.table("APP_ID", 'Test Table')
Without any extra encoding, the table name should just be a standard text. Any required encoding should be handled internally by the gem.
If the problem continues, there could be a bug in the gem itself. The appropriate action was to create an issue on the GitHub repository. The problem may be examined by the gem's maintainers, who can then offer assistance or address it in a subsequent version.
Keep in mind to provide any pertinent information on the issue, such as the gem version you're running and any error messages or stack traces you've seen. The maintainers will be better able to comprehend and solve the issue as a result.
Hopefully, the people that look after the gem will be able to help you further and offer a solution.