I am trying to fetch custom objects based on field value including '+' character. More specifically, I am fetching a Contact custom object which has an email address field.
It works fine with normal email addresses. However, I have also email addresses that include '+' character and the fetch fails.
How should I use the QBCustomObjects.getObjects API call with request builder? All hints & tips are appreciated! Thanks in advance!
Code:
QBCustomObjectRequestBuilder requestBuilder = new QBCustomObjectRequestBuilder();
requestBuilder.eq("emailAddress", “matti@iloapps.com"); // WORKS
// BUT: matti+test001@iloapps.com DOES NOT WORK
QBCustomObjects.getObjects("Contact", requestBuilder, new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
// do stuff here..
}
});
I solved this issue by doing URL encoding in order to meet HTTP POST requirements with special characters. I thought this would have been done automatically by the QB library but it wasn't.. This could be improvement to add in next versions (like in iOS library)?
Solution:
String encodedEmail = URLEncoder.encode(email, "UTF-8");