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!
Solved! Go to Solution.
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
Alexandra Boyko FYI. I moved your post to the Products and Support section of the site.
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.
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?
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
Makes sense. That's the URL encoding for a +
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 +.
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
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.