Quickblox: Fetching custom object based on field value with '+' character seems not to work? How to fix?

StackOverflow https://stackoverflow.com/questions/23263083

  •  08-07-2023
  •  | 
  •  

Question

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..
    }
});
Was it helpful?

Solution

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top