I'm stumped on this. I've been following this tutorial really closely because I'm trying to do something very similar, but everytime I call my first function I get an "InvalidSharedGroupId" error back.
This is my CloudScript function:
handlers.postToStory = function (args) { try { var getRequest = { SharedGroupId: args.sharedGroupId, Keys: [ "posts" ] }; var gameData = server.GetSharedGroupData(getRequest); log.info(gameData); } catch (e) { var msg = JSON.stringify(e); log.info(msg); } // it errors out by this point... }
Here is what I'm calling from the client (I'm working in C# / Unity):
private void SubmitPost(string text) { PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "postToStory", GeneratePlayStreamEvent = true, FunctionParameter = new { sharedGroupId = _sharedGroupId, postText = text }, }, OnSubmitPost, OnErrorShared); }
("_sharedGroupId" is a value I've cached on the client after calling "CreateGroup" to make a new group)
The error I get back is:
{ "cloudScriptErrorCode":"CloudScriptAPIRequestError", "stack":"Error\n at Object.server_request (Script:180:24)\n at Object.server.GetSharedGroupData (Script:552:75)\n at handlers.postToStory (MY_GAME_ID.js:373:31)\n at Object.invokeFunction (Script:116:33)", "apiErrorInfo":{ "api":"/Server/GetSharedGroupData", "request":{ "SharedGroupId":"MY_SHARED_GROUP_ID" }, "result":null, "apiError":{ "code":400, "status":"BadRequest", "error":"InvalidSharedGroupId", "errorCode":1088, "errorMessage":"InvalidSharedGroupId", "errorHash":null, "errorDetails":null } } }
I removed the actual shared group id for security, but I can 100% confirm the id I pass in matches the id of the group I created earlier.
So that's what I don't understand: why am I getting this error if that group *definitely* exists?
Thanks for the help!