Issue
I'm trying to set the ACL permissions for an object created through the Parse REST API. I want it to have only public read access. Only the server can create or modify the objects in the class. I read the parse REST documentation on how to set ACL permissions.
When I run the following:
$InputData = array('votes' => 1, 'ACL' => array('*' => array('read' => true, 'write' => false)), 'user' => array('__type' => 'Pointer', 'className' => '_User', 'objectId' => $objectId));
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_PORT,443);
curl_setopt($rest,CURLOPT_POST,1);
curl_setopt($rest,CURLOPT_POSTFIELDS, json_encode($InputData));
curl_setopt($rest,CURLOPT_HTTPHEADER,
array("X-Parse-Application-Id: " . $appId,
"X-Parse-Master-Key: " . $restKey,
"Content-Type: application/json"));
I get:
{"code":123,"error":"Invalid acl {\"*\":{\"read\":false,\"write\":false}}"} 1
What is wrong with my code, specifically the ACL part? Help!
Solution
Hope it helps.
curl -X POST \
-H "Content-Type: application/json" \
-H "X-Parse-Application-Id: xxxxxxxxxxxxxxx" \
-H "X-Parse-REST-API-Key: xxxxxxxxxxxxx" \
-H "X-Parse-Session-Token: xxxxxxxxxxxxxx" \
-d "{\"name\":\"MyName\", \"ACL\": {\"ErKLiQfj8Q\" : { \"read\": true, \"write\": true }, \"*\" : {}}}" \
https://api.parse.com/1/classes/Tasks
JSON obj
{
"name":"MyName",
"ACL":
{
"ErKLiQfj8Q" : { "read": true, "write": true },
"*" : {}
}
}
Answered By - Tin Megali Answer Checked By - Willingham (WPSolving Volunteer)