Support Topics Documentation Slack YouTube Blog

Backendless 4.0 Migration Issues

(Kam Rezvani) #1


I have upgraded my app to Backendless 4.0 but the client side is no longer running. I looked through documentation and looks like I need to rewrite all the Backendless calls because the syntax has changed from 3.0 to 4.0. Is this is an accurate assumption?

Here is the error message I get from the callback when I attempt to login from the mobile app using 3.0 functions calls to log into a 4.0 backend:

<!DOCTYPE html>
[INFO] :   <html>
[INFO] :   	<head>
[INFO] :   		<title>Action not found</title>
[INFO] :   		<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlFJREFUeNqUU8tOFEEUPVVdNV3dPe8xYRBnjGhmBgKjKzCIiQvBoIaNbly5Z+PSv3Aj7DSiP2B0rwkLGVdGgxITSCRIJGSMEQWZR3eVt5sEFBgTb/dN1yvnnHtPNTPG4PqdHgCMXnPRSZrpSuH8vUJu4DE4rYHDGAZDX62BZttHqTiIayM3gGiXQsgYLEvATaqxU+dy1U13YXapXptpNHY8iwn8KyIAzm1KBdtRZWErpI5lEWTXp5Z/vHpZ3/wyKKwYGGOdAYwR0EZwoezTYApBEIObyELl/aE1/83cp40Pt5mxqCKrE4Ck+mVWKKcI5tA8BLEhRBKJLjez6a7MLq7XZtp+yyOawwCBtkiBVZDKzRk4NN7NQBMYPHiZDFhXY+p9ff7F961vVcnl4R5I2ykJ5XFN7Ab7Gc61VoipNBKF+PDyztu5lfrSLT/wIwCxq0CAGtXHZTzqR2jtwQiXONma6hHpj9sLT7YaPxfTXuZdBGA02Wi7FS48YiTfj+i2NhqtdhP5RC8mh2/Op7y0v6eAcWVLFT8D7kWX5S9mepp+C450MV6aWL1cGnvkxbwHtLW2B9AOkLeUd9KEDuh9fl/7CEj7YH5g+3r/lWfF9In7tPz6T4IIwBJOr1SJyIGQMZQbsh5P9uBq5VJtqHh2mo49pdw5WFoEwKWqWHacaWOjQXWGcifKo6vj5RGS6zykI587XeUIQDqJSmAp+lE4qt19W5P9o8+Lma5DcjsC8JiT607lMVkdqQ0Vyh3lHhmh52tfNy78ajXv0rgYzv8nfwswANuk+7sD/Q0aAAAAAElFTkSuQmCC">
[INFO] :   	    <style>
[INFO] :   		    html, body, pre {
[INFO] :   		        margin: 0;
[INFO] :   		        padding: 0;
[INFO] :   		        font-family: Monaco, 'Lucida Console', monospace;
[INFO] :   		        background: #ECECEC;
[INFO] :   		    }
[INFO] :   		    h1 {
[INFO] :   		        margin: 0;
[INFO] :   		        background: #AD632A;
[INFO] :   		        padding: 20px 45px;
[INFO] :   		        color: #fff;
[INFO] :   		        text-shadow: 1px 1px 1px rgba(0,0,0,.3);
[INFO] :   		        border-bottom: 1px solid #9F5805;
[INFO] :   		        font-size: 28px;
[INFO] :   		    }
[INFO] :   		    p#detail {
[INFO] :   		        margin: 0;
[INFO] :   		        padding: 15px 45px;
[INFO] :   		        background: #F6A960;
[INFO] :   		        border-top: 4px solid #D29052;
[INFO] :   		        color: #733512;
[INFO] :   		        text-shadow: 1px 1px 1px rgba(255,255,255,.3);
[INFO] :   		        font-size: 14px;
[INFO] :   		        border-bottom: 1px solid #BA7F5B;
[INFO] :   		    }
[INFO] :   		</style>
[INFO] :   	</head>
[INFO] :   	<body>
[INFO] :   		<h1>Action not found</h1>
[INFO] :   		<p id="detail">
[INFO] :   			For request 'POST //users/login'
[INFO] :   		</p>
[INFO] :   	</body>
[INFO] :   </html>

Also, I am using a client-side Appcelerator Titanium library (backendless.js) to utilize the apis. Do I need a new version of this library for version 4.0 and if so how do I get one?


(Vladimir Upirov) #2

Hi Kam

Yes, there are a few difference between 3.x and 4.x.
Did you see the docs
And yes, you need to get JS SKD for 4.x, you can find the latest SDK here:

Let us know if we can help you with something else

Regards, Vlad

(Kam Rezvani) #3

Hi Vlad,

Thank you for the prompt reply. I changed the login syntax to match 4.x:

Backendless.UserService.login(email.value, password.value, true).then(loginSuccess).catch(backendlessError);

I get the following error when I run the code:

[WARN] : column = 9;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #d87a00} 
[WARN] : line = 5684; 
[WARN] : message = "Attempted to assign to readonly property."; 
[WARN] : sourceURL = "file:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/"; 
[WARN] : stack = "file:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/\nfile:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/\nfile:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/\nglobal code@file:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/\nrequire@[native code]\nfile:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/\nglobal code@file:///Users/kamrezvani/Library/Developer/CoreSimulator/Devices/572227C3-7202-43F5-882E-01BA32DE4A3C/data/Containers/Bundle/Application/B1C14A65-C8B8-434B-885C-90BDB486327B/";


(Vladimir Upirov) #4

Hey Kam

I tried it out just now, and looks like is everything works fine
so what were my steps:

  1. reg and install Appcelerator Studio
  2. setup env and import example “Employee Directory” from dashboard of the Appcelerator IDE
  3. ran and made sure that everything is works
  4. get the latest code of Backendless JS SDK v4.0.9
  5. put the sdk into ‘app/libs’ folder
  6. in index.js file of the app in the top I’ve added this little code
var Backendless = require('backendless')


  1. and run again, and there were no warnings and errors
  2. when the app is started in my emulator I see the alert with Backendless.serverURL

Could you debug where is actually your app crashing?

(Kam Rezvani) #5

Hi Vald,

Thank you for the reply. The warning I posted happens during the require(‘backendless’) execution. So that is probably not the problem.

What I experience is that after executing:

Backendless.UserService.login(email.value, password.value, true).then(loginSuccess).catch(backendlessError);

…is that the loginSuccess function is not being called back. I know that the login event executed on the backend by looking at lastlogin date on the console. This very same process worked with Backendless 3.x. For 4.x, I just substituted the new syntax for login but the callback functions do not execute for some reason.

I did download the backendless.js file from the link you provided. Is there a verify that I have the correct revision of this file?

Thanks for your help.


(Vladimir Upirov) #6

if you downloaded the sdk from here it’s what we need

I have tried to reproduce this, I’ve created a simple app and tried to call login and it works for me

Backendless.XMLHttpRequest = function() { return Ti.Network.createHTTPClient(); };

Backendless.UserService.login('foo@bar', '123456')
    console.log('error:', error);

ok, if you can see that “lastLogin” changes on the backend that’s mean that login method works well, so lets take a look into “loginSuccess” method, do you have any log messages in the method or could you debug the method?

maybe the problem is not with login method but somewhere else

(Kam Rezvani) #7

Hi Vald,

I reorganized my code to match the pattern you presented here but still no luck. The success callback does not execute:

			Backendless.UserService.login(email.value, password.value, false).then(function(user) {'loginSuccess');
				Titanium.App.Properties.setString('access', password.value);
				var user = Backendless.UserService.getCurrentUser();
				Titanium.App.Properties.setString('facilityName', user['Facility_Name']);
				Titanium.App.Properties.setString('facilityCity', user['Facility_City']);
				Titanium.App.Properties.setString('facilityState', user['Facility_State']);
				Titanium.App.Properties.setString('clinician', user['Clinician']);
				if (isAndroid)
				new Window().open({
				animated : true
			}).catch(function(err) {
			alert('Login error: ' + err.message);

Neither the success or failure callbacks execute. I get the ‘LoggedIN’ log entry which basically means that code executed without activating the callback routines.


(Vladimir Upirov) #8

when you use sdk version 3.x did you have async or sync code? I mean did you use:

Backendless.UserService.login(email.value, password.value, false).then(successCallback, faultCallback)


Backendless.UserService.login(email.value, password.value, false, new Backendless.Async( successCallback, faultCallback ))

or you just had:

var user = Backendless.UserService.login(email.value, password.value, false)

because now, in 4.x all methods by default returns Promises - that means the code is async
if you want to use “sync” method you have to add “Sync” word to the end of method name, for ex: “loginSync”, “registerSync”, “restorePasswordSync” etc.

so, in this case (your login method), if everything works as expected the flow must be :

  2.‘loginSuccess’); or alert('Login error: ’ + err.message);

the second step will be called after the login request is done, it may take a little time because it’s Async code

(Kam Rezvani) #9

Hi Vlad,

Thank you for your help. In 3.x, the code was as follows:

Backendless.UserService.login( email.value, password.value, true, new Backendless.Async( loginSuccess, backendlessError ));

so as you mentioned, I was using the async pattern with 3.x.

The problem is that the callback is not executing as it did in 3.x version. So I can’t help but think that there is an issue with the 4.x implementation.

The 2)‘loginSuccess’); or alert('Login error: ’ + err.message); never executes no matter how long I wait. The seamless execution of validating user credentials that took place with 3.x version does not take place with 4.x.


p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #008f00}

(Vladimir Upirov) #10

It’s as some kind of magic, I don’t understand why it works for me but not for you =(
Let’s take a look more deep

  1. do you have this one in your code ?
Backendless.XMLHttpRequest = function() { return Ti.Network.createHTTPClient(); };

could you add a few log lines into backendless.js file for check if this lines are executing:

and also what version of titanium-sdk are you using? I have v 6.1.2

and does your environment support Promise ?

(Kam Rezvani) #11

Hi Vlad,

I have the XMLHttpRequest statement in my code. It has been there since version 3.x.

I added the logging to the lines within backendless.js that you suggested and all the lines execute when I try to login.

I was using SDK 6.04. I upgraded to 6.1.2 but there was no difference in code execution.

As for Promises support, it doesn’t look like Titanium supports it:

How can I add Promises support so it works with the Backendless libray?


(Vladimir Upirov) #12

Hmm, looks like the issue with node js, what nodejs version do you have? I have 6.9.1

Try to upgrade your nodejs, are you familiar with “nvm” - Node Version Manager it’s should help you change node version

type it in your terminal

nvm install 4

install version 4 or upper

Regards, Vlad

(Kam Rezvani) #13


Here is the log of the software/hardware I am using to run the app:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}

Operating System

Name = Mac OS X

Version = 10.12.6

Architecture = 64bit

CPUs = 8

Memory = 17179869184


Node.js Version = 7.10.1

npm Version = 4.2.0

Titanium CLI

CLI Version = 5.0.14

Titanium SDK

SDK Version = 6.1.2.GA

SDK Path = /Users/kamrezvani/Library/Application Support/Titanium/mobilesdk/osx/6.1.2.GA

Target Platform = iphone

As you can see, I am using a higher node version than you have recommended. My node version is 7.1.10.


(Vladimir Upirov) #14

it’s strange, because Promise is supported in node 7.10.1

what if you try to add promise-polyfill to your app

And could you create a some small project with this problem and push it to or make archive and send it to ( with link on this topic )

Or, maybe you try to create a new project from Appcelerator sample “Employee Directory” (from studio dashboard)

I have no more ideas that I can recommend you, it would be easy if I can reproduce the problem
it’s really hard to understand what exactly does not work, is the problems with your env or with your code

Regards, Vald

(Kam Rezvani) #15

Hi Vlad,

The blocking method works:

try { 
				user = Backendless.UserService.loginSync( email.value, password.value );'loginSuccess'); 
				Titanium.App.Properties.setString('access', password.value); 
				var user = Backendless.UserService.getCurrentUser(); 
				Titanium.App.Properties.setString('facilityName', user['Facility_Name']); 
				Titanium.App.Properties.setString('facilityCity', user['Facility_City']); 
				Titanium.App.Properties.setString('facilityState', user['Facility_State']); 
				Titanium.App.Properties.setString('clinician', user['Clinician']); 
				if (isAndroid) 
				new Window().open({ 
					animated : true 
			} catch( err ) { 
				alert('Login error: ' + err.message); 

I am going forward with this but with some reservations. I would like to find out why the non-blocking method does not work but can’t really spend any more time on this. If you happen to find out please let me know as I am concerned about having bugs like this hamper my progress in the future.

Thanks for your help.


(Kam Rezvani) #16

Hi Vlad,

I am running into another problem that I am hoping you can assist me with. I updated my app’s Backendless calls to v4.x using the blocking methods (remember we couldn’t get non-blocking to work).

Everything worked perfectly for iOS however, when I began testing the Android code, I get a non-descript error message: “unknown error occurred” with error code “0”. Even though an error is thrown, when I check the login record, the date shows that the user actually succeeded in logging in.

Again, this is the blocking method for logging in and the code is posted in my previous message.


(Vladimir Upirov) #17

Hi Kam

Please create a simple app with this problem and send it to with link on the topic, it’ll help us to investigate the problem quickly.

Regards, Vlad

(Vladimir Upirov) #18

Hi Kam again =)

I’ve received your email with SampleApp
Checked it and I found out that sync calls are not supported in Android!/api/Titanium.Network.HTTPClient

but Promises works well, I sent you an email with video

Regards, Vlad