I'm trying to update some user data but am running into an error every time.
So I have an existing user:
=> {"lists"=>{"list"=>{"name"=>"All Users", "id"=>"771443", "subscriber_count"=>"159", "display_name"=>""}}}
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}