使用Parse Rest API查询关系

时间:2015-10-14 16:00:28

标签: api rest curl parse-platform

我正在尝试从类中获取关系对象。我在做什么看起来像这样,但它不起作用。有人知道我做错了什么吗?

  curl -X GET \

   -H "X-Parse-Application-Id: xxxxx" \

   -H "X-Parse-REST-API-Key: xxxx" \

   --data-urlencode 'where={"$relatedTo":{"object":{"__type”:"Relation","className”:”Dog","objectId":"xkxJOVMcMv"},"key”:"dogs"}}' \

   https://api.parse.com/1/classes/owner

谢谢!

1 个答案:

答案 0 :(得分:2)

我假设你的所有者类有一个关于Dog类的关系字段,你想通过这种关系获得所有拥有的狗。那么你应该这样做:

curl -X GET \
-H "X-Parse-Application-Id: xxxxx" \
-H "X-Parse-REST-API-Key: xxxx" \
--data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"owner","objectId":"<ownerid>"},"key":"dogs"}}' \
https://api.parse.com/1/classes/Dog