Geopoint creating with categories error "'categories' must be an array"

Hello,

We create geopoints successfully with just ‘latitude’ and ‘longitude’. Now it requires be categorized, but any attempts to create geopoint as relation with category (-ies) array throw an error:


code: 0
message: "java.lang.RuntimeException: com.backendless.exceptions.GeoException: The property 'categories' must be an array"

but the property ‘categories’ is array of cource, thi is real example (copypaste) of request logging with console.log from beforeCreate and AfterCreate handlers (presented as geopoint relation object):


"center_point": {
                    "___jsonclass": "GeoPoint",
                    "___class": "GeoPoint",
                    "categories": [
                        "mission_location",
                        "mission"
                    ],
                    "metadata": {
                        "timestamp": ""
                    },
                    "latitude": 50.0305155,
                    "longitude": 36.346605
                },

Could you please help with this issue?

Thank you!

Hi Yury,

Please provide your AppId and I’ll try to investigate the reason of your problem

Regards Vlad

Hi Vladimir!

The app id is ‘6310BC44-383B-6119-FF03-01F4D2EC6D00’.

Thank you for response.

I can create a new record via REST Console without any error

So I think reason of the problem is in your code, as I understand from previous topic you develop Android App, right?

Could you make sure that everything is Ok in your code, or you can provide a small code example for reproduce the problem

Also maybe it would be helpful for you
https://backendless.com/documentation/data/android/data_relations_with_geo_points.htm

Regards, Vlad

it is my code, the geopoint was created as 3-rd level relation object (you could see it in App as sequence ‘Mission’<-has-’[Location]’<-has-geopoint as ‘centrer_point’ ), so ‘location’ relation property of Mission object (which is request body object for creating record with POST to ‘…/data/Mission’) looks like:

 location: [
 {
 "___class": "MissionLocation", // relation defined
 center_point: {
 "___class":"GeoPoint",
 "categories": ["mission_location", "mission"],
 // OR "categories": ["mission_location"],
 "metadata": {
 "timestamp": Date.now(),
 // OR "timestamp": '',
 },
 "latitude": 50.0305155,
 "longitude": 36.346605
 },
 geofence: null,
 radius: 5,
 geofence_json: '{"name":"_some_new_geofence", .... some JSON serialized string }',
 name: "location name "
 }
 ],

and… I just have got the same error "“java.lang.RuntimeException: com.backendless.exceptions.GeoException: The property ‘categories’ must be an array”’,

but if I remove or comment line ‘“categories”: [“mission_location”, “mission”],’ - this ‘create mission’ request passes successfully.

Hi Yuri,

Do you make the request which fails from an Android, iOS or JS app? The reason I ask is so we can try reproducing it with the same client type.

Regards,
Mark

did you try to reproduce the error in REST Console?

  1. goto REST Console
  2. insert the json to RequestBody
  3. click POST button

Hello, Mark, Vladimir, sorry i was leaving.
I made request from my test JS app,

and I’ve just tested it with REST console in two our applications (the second one is 467026CB-77DD-803B-FFFB-051EBAC2A300) - and I have the same error in both apps.

http://support.backendless.com/public/attachments/e889b7054da4fbc49bf1f1f296c4adcb.png&lt;/img&gt;

Here’s full JSON of RequestBody: http://jsoneditoronline.org/?id=333ba72f4c36c2e44910c7c944d45bf0

Hi Yuri,

This is rather odd. I tried POST-int the same request into a newly created table and it worked. What is the name of the data table you’re inserting it to?

Regards,
Mark

The name is the same as on the screenshot in ‘Request URL’ field - ‘Mission’.

Hi Yury,

We figured out what’s going on:

A request to create a Missing object enters your beforeCreate event handler. When it happens, the entire object is sent to CodeRunner and when it comes back to the core application server (all on the server-side), it is reconstructed slightly differently. Specifically, the “categories” property in the geopoint becomes an array rather than an expected list. As a result, the error occurs. You can actually see the object properly saved if you disable the beforeCreate event handler for the Mission table.

We will fix it, and as an interim solution, you could do the following:

    Save MissionLocation first. Once you have the objectId of MissionLocation, reference it in the Mission object the same way you save "type"
Regards, Mark

Mark, thank you for support.

Hi Yury

The issue has been fixed. Please verify and let us know here regarding the results.

Regards Anton