Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `keys' for "OtherField":String #30

Closed
richymontz opened this issue Oct 11, 2017 · 3 comments
Closed

NoMethodError: undefined method `keys' for "OtherField":String #30

richymontz opened this issue Oct 11, 2017 · 3 comments

Comments

@richymontz
Copy link

I had an error when I try to do a request to get custom_fields from my Drip account.
This is the code line: client.get("#{client.account_id}/custom_field_identifiers", {}), "OtherField" is one of my custom fields

@rdunlop
Copy link

rdunlop commented Apr 13, 2018

I have run into this today too. the custom_fields call does not appear to work.

The curl command works fine though.

curl "https://api.getdrip.com/v2/<redacted>/custom_field_identifiers"  -H 'User-Agent: Your App Name (www.yourapp.com)' -u <redacted>:
{"custom_field_identifiers":["First_name","Last_name","first_name","last_name"]}

but calling client.custom_fields causes:
NoMethodError (undefined method `keys' for "First_name":String)

@will-in-wi
Copy link
Contributor

I'm having some trouble reproducing. Is this still an issue in the latest version?

@eterry1388
Copy link

Reproduced.

This code (taken directly from documentation here) raises an exception.

require 'drip'

client = Drip::Client.new do |c|
  c.api_key = "YOUR API KEY"
  c.account_id = "YOUR_ACCOUNT_ID"
end

response = client.custom_fields . # <- Exception occurs here

Exception:

/Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/resource.rb:32:in `block in process': undefined method `keys' for "first_name":String (NoMethodError)
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/resource.rb:31:in `tap'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/resource.rb:31:in `process'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/resource.rb:9:in `initialize'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/collection.rb:27:in `new'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/collection.rb:27:in `block in parse_items'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/collection.rb:26:in `map'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/collection.rb:26:in `parse_items'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/collection.rb:9:in `initialize'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:59:in `new'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:59:in `block (2 levels) in parse_members'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:52:in `each'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:52:in `block in parse_members'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:50:in `tap'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:50:in `parse_members'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/response.rb:13:in `initialize'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/client.rb:119:in `new'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/client.rb:119:in `build_response'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/client.rb:85:in `make_request'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/client.rb:61:in `get'
  from /Users/ericterry/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/drip-ruby-3.1.1/lib/drip/client/custom_fields.rb:9:in `custom_fields'

To reproduce, be sure you have custom fields on the account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants