I'm using a third party service QuickBlox to manage a backend of my app. Users can input text and create objects on the backend. However, when I create a POST request to https://api.quickbloc.com/users.json and attempt to send special characters the QuickBlox library creates a data object that looks like this:
user = {
login = "\U00e1\U00e9\U00ed\U00f3\U00fa";
password = ssssddddd;
};
However, QuickBlox then responds with "should contain alphanumeric and punctuation characters only"
I have tried make the request manually to QuickBlox and have discovered that the data being posted should look like this:
{"user": {
"login":"\\U00c1\\U00e1\\U00e9\\U00ed\\U00f3\\U00fa",
"password":"sdddddddd"
}
}
The request is being constructed using QuickBlox pod and it has the following headers:
[QBCore] Request headers: {
"Accept-Language" = "ga;q=1, en-GB;q=0.9, en;q=0.8";
"Content-Type" = "application/x-www-form-urlencoded";
"QB-OS" = "iOS 8.4";
"QB-SDK" = "iOS 2.7.2";
"QB-Token" = xxxxxx;
"QuickBlox-REST-API-Version" = "0.1.1";
"User-Agent" = "tomhais/1.0 (iPhone; iOS 8.4; Scale/2.00)";
}
and send the request parameters as follows:
{
user = {
login = "\U00e1\U00e9\U00ed\U00f3\U00fa";
password = ssssddddd;
};
}
I'm unsure how to escape the data being sent so that it isn't rejected. I'm using IOS Objective C
I'm creating the Request like this:
QBUUser *user = [QBUUser new];
user.password = password;
user.login = userName; // where userName is an NSSTRING
[QBRequest signUp:user successBlock etc etc
It's only a limited set of special characters that I need to send so I even tried a hack like this to try get them through:
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"Á" withString:@"\\Á"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"á" withString:@"\\á"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"É" withString:@"\\É"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"é" withString:@"\\é"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"Í" withString:@"\\Í"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"í" withString:@"\\í"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"Ó" withString:@"\\Ó"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"ó" withString:@"\\ó"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"Ú" withString:@"\\Ú"];
_ainmInput.text = [_ainmInput.text stringByReplacingOccurrencesOfString:@"ú" withString:@"\\ú"];