getting error "undefined method `map' ..." when trying to PUT to /audience_members/<email>

86 views
Skip to first unread message

michel...@gmail.com

unread,
Jun 30, 2013, 10:51:28 PM6/30/13
to madmi...@googlegroups.com
I'm trying to update some user data but am running into an error every time.

So I have an existing user:
$ MADMIMI.memberships("te...@test.com")
 => {"lists"=>{"list"=>{"name"=>"All Users", "id"=>"771443", "subscriber_count"=>"159", "display_name"=>""}}} 

But if I try to update that user by issuing a PUT request to http://api.madmimi.com/audience_members/te...@test.com
with body:
name=abc&username=XXX&api_key=XXX

the response I get back is:
"{\"error\":\"undefined method `map' for nil:NilClass\",\"success\":false}" 

any idea what that could be?  (full ruby code below)

thanks

-Jeff



I'm using the madmimi ruby gem which doesnt have a PUT method so I added one:
class MadMimi
  MIMI_UPDATE_PATH = ' /audience_members/%email%'
  
  def do_put_request(path, options = {})
    options = options.merge(default_opt)
    resp = href = ""
    
    http = Net::HTTP.new(BASE_URL, 80)
    begin
      http.start do |http|
        req = Net::HTTP::Put.new(path)
        req.body = URI.encode_www_form(options)
        req.content_type = 'application/x-www-form-urlencoded'
        response = http.request(req)
        resp = response.body.strip
      end
    rescue SocketError
      raise "Host unreachable."
    end
  end
  
  def audience_update(email, params)
    do_put_request(MIMI_UPDATE_PATH.gsub('%email%', email), params)
  end
end

If I then run from the console:
$ response = MADMIMI.audience_update("te...@test.com", {"name" => "abc"})
$ JSON.parse(response)
=> {"error"=>"undefined method `map' for nil:NilClass", "success"=>false}


Reply all
Reply to author
Forward
0 new messages