Searching for person by email does not work, ruby

Bonjour,

Using the new search endpoints (never tried the old search points though, began using your API a week ago), it works with names but not with emails. What am I doing wrong?

Here’s the method (Ruby)

def self.gem(email)
   url = URI("https://api.pipedrive.com/v1/persons/search?api_token=#{Rails.configuration.pipedrive_api_key}&fields=email&term=#{email}?")
   http = Net::HTTP.new(url.host, url.port)
   http.use_ssl = true
   http.verify_mode = OpenSSL::SSL::VERIFY_NONE
   request = Net::HTTP::Get.new(url)
   request["Accept"] = "application/json"
   request["Content-Type"] = 'application/json'
   response = http.request(request)
   hash_response = JSON.parse(response.body)
   p hash_response
end

Result from running (asterisks added for privacy):

Pipedrive.gem('j*k@lev********ti.com')

{"success"=>true, "data"=>{"items"=>[]}, "additional_data"=>{"pagination"=>{"start"=>0, "limit"=>100, "more_items_in_collection"=>false}}}

If I search for a name, and replace the corresponding line with

url = URI("https://api.pipedrive.com/v1/persons/search?api_token=#{Rails.configuration.pipedrive_api_key}&fields=name&term=#{name}?")

running (added *s for privacy):

Pipedrive.gem('J***e K****l')" 

returns

{"success"=>true, "data"=>{"items"=>[{"result_score"=>0.29955, "item"=>{"id"=>***, "type"=>"person", "name"=>"J***e K****l", "phones"=>[], "emails"=>["j*k@levi********i.com"], "visible_to"=>3, "owner"=>{"id"=>1******5}, "organization"=>{"id"=>1*7, "name"=>"L********ay", "address"=>nil}, "custom_fields"=>[], "notes"=>[]}}]}, "additional_data"=>{"pagination"=>{"start"=>0, "limit"=>100, "more_items_in_collection"=>false}}}

Where is my mistake?

Thanks!

Have you had a chance to test on the API Reference page to see if it works there for you?

Also, one of our developers noticed it might be the question mark you’ve got at the end here.

Just tried the api reference and I was missing the

&start=0&

But now it works! Thanks!

Questions? Reply or pick the time that works best for a 15 minute talk here: www.calendly.com/woyago

Anto from Woyago.com
ohlala@woyago.com