cartodb-rb-client icon indicating copy to clipboard operation
cartodb-rb-client copied to clipboard

Creating a table from a GeoJSON feature collection fails

Open afiore opened this issue 13 years ago • 2 comments

Hi there, I am playing around with CartoDB, and I am trying to import a GeoJSON dataset into a table using the Ruby API client. When I upload the dataset using the CartoDB web-based UI, everything works as expected. However, I cannot import the same dataset programmatically using the method call illustrated in the README file:

CartoDB::Connection.create_table "my table", File.open("/tmp/heathrow-flight-arrivals.json", "r")

/home/andrea/.rvm/gems/ruby-1.9.2-p290/bundler/gems/cartodb-rb-client-a9912041a039/lib/cartodb-rb-client/cartodb/client/connection/cartodb.rb:224:in `block in cartodb_request': There were errors running the POST request   "https://afiore.cartodb.com:443/upload": (CartoDB::Client::Error)
      401 - Unauthorized request
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/request.rb:175:in `call'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/request.rb:175:in `call_handlers'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/hydra.rb:222:in `handle_request'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/hydra.rb:191:in `block in get_easy_object'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/easy.rb:376:in `call'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/easy.rb:376:in `failure'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/multi.rb:21:in `multi_perform'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/multi.rb:21:in `perform'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/gems/typhoeus-0.3.3/lib/typhoeus/hydra.rb:95:in `run'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/bundler/gems/cartodb-rb-client-a9912041a039/lib/cartodb-rb-client/cartodb/client/connection/cartodb.rb:239:in `execute_queue'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/bundler/gems/cartodb-rb-client-a9912041a039/lib/cartodb-rb-client/cartodb/client/connection/cartodb.rb:49:in `create_table'
    from /home/andrea/.rvm/gems/ruby-1.9.2-p290/bundler/gems/cartodb-rb-client-a9912041a039/lib/cartodb-rb-client/cartodb/client/connection/base.rb:20:in `method_missing'
    from /home/andrea/code/extraloop-redis-storage/lib/extraloop/redis-storage/remote_store/cartodb.rb:34:in `push'

I should stress that I have successfully initialised the client and that I can successfully create tables and execute queries using the same connection.

Thanks, Andrea

afiore avatar Mar 18 '12 19:03 afiore

Sorry Andrea, this feature depends on a cartodb update which has to be deployed. That's why we haven't published a new version of the gem yet.

Anyway, if you want to make it work in your development environment, you can setup a local cartodb instalation, and point your ruby client to it. You'll find the installation proccess in the cartoDB readme.

Ferdev avatar Mar 21 '12 15:03 Ferdev

Thanks for the clarification Fernando. I guess I will wait for a new version of the gem..

afiore avatar Mar 21 '12 15:03 afiore