0

I've using CK Web services very successfully, but I am stumped about how to create a CKReference.

I've looked at the docs here re Reference Dictionaries, but can't make such a dictionary work.

My php generates the following operations dictionary:

{"operations":[
{"operationType": "create",
"record": { "recordType": "Works",
     "fields": {
          "type":{"value":"Painting"},
          "title": {"value":"test"},
          "date": {"value":"10/29/1965"},
          "height": {"value":"21"},
          "length": {"value":"21"},
          "width": {"value":"21"},
          "runningTime": {"value":""},
          "materials": {"value":"test"},
          "description":{"value":"test"},
          "saleStatus": {"value":"yes"},
          "tos":{"value":"yes"},
          "artist": {"value":"Peter Wiley"},
          "artistRecordName":{"value":"286CB3BF-69CC-4DD3-9233-CC80E5FA95D4"},
          "artistRecordRef": {
               "recordName": {"value":"286CB3BF-69CC-4DD3-9233-CC80E5FA95D4"},         
               "zoneID":{"zoneName": {"value":"_defaultZone"}},
               "action": {"value":"NONE"}
          },
          "subject":{"value":""},
          "metaType":{"value":"Fine Art"},
          "userRecordName":{"value":"30C54AD8-3701-428C-99B7-0393DD2DAB45"},
          "userRole":{"value":"Artist"},
          "status":{"value":"P"}
     }
} }
]}

This request returns the error:

BAD_REQUEST" [1]=> string(62) "BadRequestException: Unexpected input at [line: 26, column: 3]

If I remove the "artistRecordRef" the request works as it should.

I am sure the answer is obvious to a more experienced eye. Can someone see what's wrong?

4

1 回答 1

1

好的,我在这里找到了答案,但是已经为可能有问题的其他人发布了,因为答案不容易找到。

这是有效的:

"artistRecordRef": {"value": {
                "recordName": "'.$artistRecordName.'",
                "action": "NONE"
            }
        },

参考字典必须作为值传递。我没有得到这个,Apple 文档中的示例也没有很好地记录(至少在我能够找到的那些示例中)。

请参阅:如何使用 CloudKit Web 服务根据参考字段进行查询?

于 2017-07-21T12:01:23.953 回答