shrey August 17, 2020, 12:30pm 1 Hello all,
Could anyone advise me with regards to the following scenario:
I have a ‘List’ class with a ‘Shared with’ field (type Relation) linked with the ‘User’ class. I would like to make a REST api GET call that reads all the ‘List’ objects which have been ‘Shared with’ a particular individual/set of ‘Users’. What would be the syntax for such a call?
Thanks.
Something like this should work for a single user but I think there is no easy solution for a set of users. You can use aggregate though.
curl -X GET \ -H "X-Parse-Application-Id: ${APPLICATION_ID}" \ -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \ -G \ --data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"User","objectId":"8TOXdXf3tz"},"key":"shared"}}' \ https://YOUR.PARSE-SERVER.HERE/classes/List
shrey August 18, 2020, 4:57am 3 Hi @davimacedo , i’m unable to get your code to work.
Scenario: GET call to:
https://YOUR.PARSE-SERVER.HERE/classes/List
Result:
{ “results”: [ { “objectId”: “FBNaDwSYcO”, “Title”: “Test1”, “shared”: true, “enabled”: true, “createdAt”: “2020-08-17T06:16:00.238Z”, “updatedAt”: “2020-08-17T15:03:10.990Z”, “createdBy”: { “__type”: “Pointer”, “className”: “_User”, “objectId”: “eiKlmlIy6i” }, “sharedWith”: { “__type”: “Relation”, “className”: “_User” } }, { “objectId”: “SDyLEXbgAM”, “createdBy”: { “__type”: “Pointer”, “className”: “_User”, “objectId”: “eiKlmlIy6i” }, “Title”: “Test2”, “shared”: true, “enabled”: true, “createdAt”: “2020-08-17T15:21:10.009Z”, “updatedAt”: “2020-08-17T15:21:35.435Z”, “sharedWith”: { “__type”: “Relation”, “className”: “_User” } } ] }
Scenario: GET call to
https://YOUR.PARSE-SERVER.HERE/classes/List?where={“$relatedTo”:{“object”:{“__type”:“Pointer”,“className”:“User”,“objectId”:“wHBFNlyTOs”},“key”:“sharedWith” }}
Result:
{
"results": [] }
Only this is working at the moment: Scenario: GET call to
https://YOUR.PARSE-SERVER.HERE/classes/List?where= {“shared”: true,“enabled”: true,“sharedWith”:{“__type”:“Pointer”,“className”:“User”,“objectId”:“wHBFNlyTOs”}}
Could you please try one more time with "className": "_User"?