question

Thomas McLain avatar image
Thomas McLain asked

Getting "InvalidSharedGroupId" error from CloudScript function

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!

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

Are you able to search out that group id in this page https://developer.playfab.com/en-US/your_title_id/shared-group-data?

0 Likes 0 ·

1 Answer

·
Thomas McLain avatar image
Thomas McLain answered

I actually figured this out. I was pretty new to all of this, and I was getting "shared groups" and "groups" mixed up. So I had actually created a group using the groups api; I hadn't made a shared group.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

Oh, sorry that I didn't notice you were using CreateGroup, which is a "groups" API. And, yes, "shared group" and "groups" are two distinct features, which cannot be used interchangeably. So, It's working well for you now, right?

0 Likes 0 ·
Thomas McLain avatar image Thomas McLain Citrus Yan commented ·

Hey, yeah! I'm all good now. Thanks! I should probably close this, huh?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.