Hi -
An already logged-in user tries to register another user - but the registration attempt fails with – “BackendlessException{ code: ‘3039’, message: ‘You cannot provide user id for registration.’ }”.
What does this mean ?? I am using custom property “user_id” as identity, and also providing all properties marked as required in backend.
Please help - not able to think of any workaround.
Code:
public int registerCustomerSync(String custMobile) {
Log.d(TAG, "In registerCustomerSync: "+custMobile);
int errorCode = ErrorCodes.NO_ERROR;
BackendlessUser customer = new BackendlessUser();
customer.setProperty("user_id", custMobile);
customer.setProperty("mobile_no", custMobile);
backendUser.setPassword(generatePassword());
backendUser.setProperty("user_type", AppConstants.USER_TYPE_CUSTOMER);
backendUser.setProperty("disable_reason", AppConstants.custAccQRCodeNA);
try
{
backendUser = Backendless.UserService.register( backendUser );
}
catch( BackendlessException e )
{
Log.e(TAG,"Customer register failed: "+e.toString());
// Handle backend error codes
String error = e.getCode();
errorCode = ErrorCodes.GENERAL_ERROR;
if (error.equals(ErrorCodes.BL_ERROR_REGISTER_DUPLICATE)) {
errorCode = ErrorCodes.USER_ALREADY_REGISTERED;
}
}
return errorCode;
}
Thanks.
Regards,
Aditya
Could you please attach a screenshot showing user properties of your app? (the Schema for the Users table)
It mean that you can not provide ‘objectId’ property when register new user.
as I can see you create ‘customer’ object, and then you try to register ‘backendUser’ and I suppose that ‘backendUser’ contains property ‘objectId’
What do you mean by - "I suppose that ‘backendUser’ contains property ‘objectId’?? - I did not set the ‘objectId’ property in backendUser !!
Code again below - I simply create a 'BackendUser; object (named customer), sets few of its properties (not objectId) - and tries to register it - am I doing something wrong here ???
BackendlessUser customer = new BackendlessUser();
customer.setProperty(“user_id”, custMobile);
customer.setProperty(“mobile_no”, custMobile);
backendUser.setPassword(generatePassword());
backendUser.setProperty(“user_type”, AppConstants.USER_TYPE_CUSTOMER);
backendUser.setProperty(“disable_reason”, AppConstants.custAccQRCodeNA);
try
{
backendUser = Backendless.UserService.register( backendUser );
You create instance of Backendless user here:
BackendlessUser customer = new BackendlessUser();
Notice the variable name is “customer”. Then you call the register API:
Backendless.UserService.register( backendUser );
Notice the variable name is now “backendUser”. So what happened to the variable “customer”? Looks like you create one instance, but use another one to register a user.
Mark
ohh man …no way …how could i miss that …i feel guilty to open a ticket for such stupid mistake …I am really sorry guys to waste your time like this …will be extra careful from next time …Thanks a ton !!!