Bug in REST + MondoDB + ObjectIds in a list

I’m seeing a repeatable bug when trying to modify a field which is an array of ObjectIDs.

If I use some other tool (MongoDB Compass or Python), I can readily create records that have array of ObjectIDs. DreamFactory REST API is able to GET these, like this:

{
"resource": [
    {
        "_id": "5c86919fe0e8ca62bcc4e1ae",
        "name": "group_C",
        "desc": "CCC",
        "date1": {
            "$date": "2019-01-01T00:00:00+00:00"
        },
        "date2": {
            "$date": "2019-01-02T00:00:00+00:00"
        },
        "sensors": [
            {
                "$oid": "5c65d1db2889652d840b31de"
            },
            {
                "$oid": "5c65d1db2889652d840b31dc"
            }
        ]
    }
  ]
}

Note the two “$oid” fields in the “sensors” array.

But attempting to POST, PUT, or PATCH works ONLY if I limit the “sensors” field to ONE ObjectID:

        "sensors": [
            {
                "$oid": "5c65d1db2889652d840b31de"
            }
        ]

If I try to use two like this:

       "sensors": [
            {
                "$oid": "5c65d1db2889652d840b31de"
            },
            {
                "$oid": "5c65d1db2889652d840b31dc"
            }
        ]

I get this error:

       {
           "code": 22,
           "message": "invalid document for insert: keys cannot begin with "$": "$oid""
       }

Help! I’m using DreamFactory 2.12.0.

Hi @dharasty,

Thank you for bringing this to our attention. We will take time to dive deeper into this issue and file a report on it.

Best,
Kevin

Hey, @Kevin_Mcgahey… any progress on this? Still a problem…

Probably related to Cannot update field of type ObjectId in MongoDB