SOLVED

api search by email like test+1@gmail.com

Go to solution
Anonymous
Not applicable

api search by email like test+1@gmail.com

Hi everyone,

I need to search leads via API by mail.

I use call /rest/v1/leads.json?filterType=email&filterValues=test+1@gmail.com

it returns nothing.

It looks like the problem with "+" sign in email.

It returns leads with emails without "+" and does not return leads with emails with "+"...

Are there any ways to escape +?

Does not work as well:

/rest/v1/leads.json?filterType=email&filterValues='test+1@gmail.com'

/rest/v1/leads.json?filterType=email&filterValues="test+1@gmail.com"

Thanks in advance - any help/suggestions appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: api search by email like test+1@gmail.com

I managed to get the following to work instead of the + char;

%2B

So you would request /rest/v1/leads.json?filterType=email&filterValues=test%2B1@gmail.com

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Re: api search by email like test+1@gmail.com

Alexandra Boyko​ FYI. I moved your post to the Products and Support​ section of the site.

Elliott_Lowe1
Level 9 - Champion Alumni

Re: api search by email like test+1@gmail.com

We had a similar problem with Server Side From Post to Marketo where the plus character was converted to a blank character.  I think we replaced the '+' character with its HTML equivalent (%43) and that solved the problem.  We may have had to convert all the fields' characters to their HTML equivalent.

Grant_Booth
Level 10

Re: api search by email like test+1@gmail.com

I would need to test it, but I suspect the "+" is a reserved character in the database query. If you try URL encoding it as a %43 as Elliot suggests, does that work?

Anonymous
Not applicable

Re: api search by email like test+1@gmail.com

I managed to get the following to work instead of the + char;

%2B

So you would request /rest/v1/leads.json?filterType=email&filterValues=test%2B1@gmail.com

Grant_Booth
Level 10

Re: api search by email like test+1@gmail.com

Makes sense. That's the URL encoding for a +

HTML URL Encoding Reference

Anonymous
Not applicable

Re: api search by email like test+1@gmail.com

Thanks, %2B works fine
Intersting, that rest/v1/leads.json with

   "action":"createOrUpdate",

   "lookupField":"email",

   "asyncProcessing":"true",

   "input":[ 

      { 

         "email":"123+1@any.com",

         "firstName":"test1"

      }    

    ]

}

works fine and updates lead with email with +.

Grant_Booth
Level 10

Re: api search by email like test+1@gmail.com

Hi Alexandra,

That's because the + there is contained in the body of a POST, rather than in a URL parameter of a GET. The body of a POST doesn't need to be URL encoded in the same way.

-Grant

SanfordWhiteman
Level 10 - Community Moderator

Re: api search by email like test+1@gmail.com

You're POSTing in the JSON format, which doesn't need the + to be encoded in a special way because + isn't part of the JSON delimiting structure itself.  If, however, you needed to put a " (double quotation mark) character in your JSON post, you'd need to escape it as \" because quotes are used in a special way in JSON.

If your POST were sent in the x-www-form-urlencoded format, then it would be subject to exactly the same rules as a GET request, and you would have to use %2B.

Almost every data format has at least one character that needs to be treated specially in order to not interfere with parsing that format.  An exception is fixed-size formats, where a long string is always split up at preset points (characters 1-8, characters 9-25, and characters 26-50, for example) so it doesn't matter what characters are used in each section of the string.