I have two relations field to User table, 1) geoPoint (geo point relations) 2) photo (data object relationship), both of them are 1 - 1 relation and autoload is set.
After log in, if photo relation does not exist, I create and update photo relation object.
Updating photo object fails with below error message.
java.lang.RuntimeException: java.lang.RuntimeException: com.backendless.exceptions.GeoException: The property ‘categories’ must be an array
Before updating photo relation object, I successfully retrieved geo relation object, and I am not even updating geoPoint.
Can you take a look at my app? This is unusual, something is going on with my app.
I’ve attached screenshot.
This issue didn’t appear until I had issue with adding unmapped variable to photo mapping class. (java)
After having “unmapped variable issue”, GeoException was thrown from the server so I removed relation fields from user table and recreated Photo table, and issue was gone. But today it appears again.
Thanks.
Hello, Scott. We are trying to find the reason of your problem. You wrote: “Before updating photo relation object, I successfully retrieved geo relation object, and I am not even updating geoPoint.”. Could you see what type of data, you send in “categories” field of geoPoint object. It looks, like seem, you send single “string” name of category field.
I don’t think it has anything to do with GeoPoint unless iOS SDK has problem - After log in, GeoPoint relation object is retrieved without a problem, did not change anything to any properties, then updated user property with photo relation object.
If photo object exists(don’t have to create photo object), there’s no problem updating both GeoPoint and Photo.
I really think that “unmap variable issue” somehow caused this issue - I’ve tested many times and had no problem until I save photo with unmapped variable of type JSONArray.
Exception: “java.lang.RuntimeException: java.lang.RuntimeException: com.backendless.exceptions.GeoException: The property ‘categories’ must be an array”, says that, when you try to update geoPoint object, the “categories” field contains string instead of array.
The “unmapped variable issue” is caused by not having “@ExcludeProperty”.
Please read below.
remove 5 and 6 - I did not have @ExcludeProperty when I updated, and fileArray does not have getter and setting.
There is one method within photo.class named int getReult() and there’s no table field named result and this caused to create field result.
To add to 10, it didn’t display any photo object in console.
Everything else is correct.
To add,
15. added @ExcludeProperty
16. There’s no problem creating and updating both photo and geoPoint until yesterday.
17. today, I am getting “geopoint category error”
Before I ask you above question, I had class varaiable JSONArray fileArray; and method “int getResult()” in Photo mapping class. I tried to update photo entity, but server responded with error. Then when I try again, server responded with “geoPoint category error”(current response error), so I looked photo table from console, fileArray and result field were created, but no data were shown and I could not create photo entity from console as well.
So I deleted user fields photo and geoPoint from user table and removed photo table. I recreated photo table and fields for user table, and everything worked fine, util today.
As you suggested, java client mapping class is fixed is fixed, and I didn’t even run java code today.
Sorry, the picture is still not clear to me… too many details…
Let’s establish some facts (correct anything that is wrong here):
You have a class called Photo
Instances of Photo are stored in a table called Photo
You have a property called "fileArray" in the Photo class.
The type of "fileArray" is JSONArray
The "fileArray" property is accessible with get/set methods.
You used @ExcludeProperty annotation to eliminate "fileArray" from serialization
After you did (6), you send API call to update an instance of Photo, server reported an error
Then you tried the same thing as above again and server send completely different error. This time saying "geoPoint category error"
After that you checked Photo table and saw that "fileArray" was there
Adding objects from console didn't work either
You removed fields "photo" and "geoPoint" from Users
You removed "Photo" table.
You created "Photo" table again
You added fields from (11) back to Users
Did I miss anything?
I don’t even change geoPoint, and besides, iOS SDK only provide passing categories with arrays when creating GeoPoint. I’ve been using this code for 6 months.
Does “geopoint category error” happen only when you update a photo object?
Does update fail for all photo objects or only a specific one?
Can you retrieve photo objects?
What geo categories do you have in the app?
Does the photo object you update have a related geoPoint?
If it does, what geo category that geoPoint belongs to?
What property did you add @ExcludeProperty for?
JSONArray fileArray
Does “geopoint category error” happen only when you update a photo object?
I don’t know, didn’t try to update other object.
Does update fail for all photo objects or only a specific one?
Currently creating new photo object fails. Updating existing photo object does not have problem.
Can you retrieve photo objects?
Yes.
What geo categories do you have in the app?
Defaults, AllUsers
Does the photo object you update have a related geoPoint?
No
If it does, what geo category that geoPoint belongs to?
Currently, saving existing photo object has no problem.
I have to sleep now it’s 4:30 am here in Korea.
If you want me to run any test, or questions please write, I will check first thing in the morning.
As I tested regarding your question “Does “geopoint category error” happen only when you update a photo object?”
Even if I try to update other properties, including non-related object, I get the same error.
Mark,
I found something that might be helpful to you.
geoPoint is autoloaded without category
I alway create/update geoPoint within category “AllUsers”.
Right after login, related object geoPoint is autoloaded, but category is empty.
The following is print out of geoPoint object
<GeoPoint> LAT:37.50191133892279, LON:127.0349053834475, distance:0, CATEGORIES:(
), METADATA:{
}, objectId = 00F4D50D-642B-1C66-FF84-646D4CA45F00
So before I create/update photo entity, I simply add category to geoPoint and update photo and geoPoint like below.
if(User.geoPoint) { //if autoloaded geoPoint is not null, simply create new geoPoint and set object id to make sure it has category
GeoPoint* geoPoint = [GeoPoint geoPoint:(GEO_POINT){.latitude=lat, .longitude=lon} categories:@[@“AllUsers”]];
[geoPoint setObjectId:User.geoPoint.objectId];
User.geoPoint = geoPoint;
}
//update geoPoint as well, to prevent “geoPoint category error”
[backendless.userService.currentUser updateProperties:@{@“photo”:User.photo,@“geoPoint”:User.geoPoint}];
[backendless.userService update:backendless.userService.currentUser response:^(BackendlessUser *user)
Even if I make sure category exists, I get the same error “geoPoint category error”
unlinking related geoPoint, there’s no problem creating photo relation object
I think this issue has nothing to do with Photo, and it just happen to show after photo umapped issue.
You can easily reproduce the issue in the following way.
add fields to user table
a) dummyInt - int type
b) geoPoint - GeoPoint relationship, autoload enabled
from console, create GeoLocation category “Location” and add a coordinate
from console, link testUser’s user.geoPoint to 2)
log in with testUser and get geoPoint props and see if category “Location” exists (you will see that category array is empty)
try to update dummyInt - you should receive “geoPoint category error”
Now, before you do 5), even if you set category for geoPoint, you will still get “geoPoint category error” as result of 5)
Note that I tested with iOS client, but I would expect that android client using android SDK will have the same issue as it looks like it’s a server issue.
Hi Scott!
I created internal task for resolving this issue.
For resolving this issue on your side you can run additional find request
to users table (server will return geo point with categories).
Regards,
Kate.