I'm trying to query CloudKit for a simple object where the name equals a string but I am getting back a BadRequestException
.
The RecordType is "Teacher" with parameters "Name" and "Grade".
I'm guessing there is something wrong with my query filter but can't find anything out of spec for Apple's reference.
{"query": {
"filterBy": {
"fieldName": "Name", "fieldValue": {
"type": "STRING", "value": {
"Name": "Teacher 1"
}
},
"comparator": "EQUALS"
},
"recordType": "Teacher"
},
"zoneID": {"zoneName": "_defaultZone"}
}
Resulting Error:
{u'serverErrorCode': u'BAD_REQUEST', u'reason': u'BadRequestException: Invalid value, expected type STRING but actual value was object of class com.apple.cloudkit.ws.application.common.data.UnknownTypeModel', u'uuid': u'c254448d-130e-4c6c-8170-554d976a1789'}
You do not need to put the field name in again, as "Name"
is already set in the "fieldName"
parameter. In fieldValue
, it only needs to be {"value":"Teacher 1"}
.
(The inspiration to the solution came from CloudKit JS Sample Code Error).