so my code works with ParseReact.Mutation.AddRelation , here it is:
ParseReact.Mutation.AddRelation({ "className": newRow.className, "objectId": newRow.id.objectId}, 'groceryRequestRelation',[{ "__type":"Pointer", "className":"ClassThePointerPointingTo", "objectId":"ObjectIdOfClassThePointerIsPointingTo" }]).dispatch()
@naoisegolden you did not put .dispatch() at the end of AddRelation so this could be a problem.
One more thing that required me to find out forever if I was the wrong objectId in my AddRelation , I should be using the objectId of the class that points to the pointer , but I used the objectId class to which the relation belongs ...
If this does not work for you, try the REST method:
var data = { "groceryRequestRelation":{"__op":"AddRelation", "objects": [{ "__type":"Pointer", "className":"ClassThePointerIsPointingTo", "objectId":"ObjectIdOfClassThePointerIsPointingTo" } ] } }; var url = "https://api.parse.com"; url += "/1/classes/Classname/objectId"; fetch(url, { method: 'put', headers: { 'Accept': 'application/json', 'X-Parse-Application-Id': PARSE_APP_ID, 'X-Parse-REST-API-Key': PARSE_REST_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then((response) => { console.log("inside add relation rest") console.log(response); return response.json(); }) .then((responseText) => { console.log(responseText); }) .catch((error) => { console.warn(error); }) .done();
source share