cartellonegerardo avatar image
cartellonegerardo asked

Trying to call SetObject cloudscript but not working.

My goal is just to have my client change data in another users account.

It's suppose to be a notification that the client user requested to chat. Later the user that recieved the data should do a GetObjects to see if he has a chat request. This question is related a bit to the question @Gosen Gao answered :

here is my javascript cloudscript code:

handlers.askChat = function (args, context) {
 		Id: args.ReceiverEntityId,
 		Type: "title_player_account",
 		TypeString: "title_player_account"
 		ObjectName: "ChatRequests",
 		DataObject: {IdUserRequesting:currentPlayerId}

I also tried this version:

handlers.askChat = function (args, context) {
    var headers = {
        "X-EntityToken": entity.GetEntityToken()//this is just a guess from what I read in the api
    var body = {
        Entity: {Id: args.ReceiverEntityId,Type: "title_player_account",TypeString: "title_player_account"},
        Objects: [{ObjectName: "ChatRequests",DataObject: currentPlayerId}]

    var url = "
";//i put my correct title id
    var content = JSON.stringify(body);
    var httpMethod = "post";
    var contentType = "application/json";
    // The pre-defined http object makes synchronous HTTP requests
    var response = http.request(url, httpMethod, content, contentType, headers);
    return { responseContent: response };

i think i feel more comfortable using the code above with the HTTP request since I'm not sure I understand how the first piece of code is written based from the API:.

If there is documentation about that would appreciate to know where.

Here is my unity code : (friendInfoCon.FriendPlayFabId I checked, does indeed give me the playfab id as expected, it comes from me having used PlayFabClientAPI.GetFriendsList somewhere else in my code)

using PlayFab;
using PlayFab.ClientModels;
using PlayFab.CloudScriptModels;

FriendInfo friendInfoCon;
private void CallAskChatFunction()
        var request = new ExecuteCloudScriptRequest
            FunctionName = "askChat",
            FunctionParameter = new
                ReceiverEntityId = friendInfoCon.FriendPlayFabId
            GeneratePlayStreamEvent = true

        PlayFabClientAPI.ExecuteCloudScript(request, (PlayFab.ClientModels.ExecuteCloudScriptResult result) => {

            if(result!=null&& result.FunctionResult!=null)
            Debug.Log($"function askChat called result: {result.FunctionResult.ToString()}");
             Debug.Log($"function askChat called null results");

        (PlayFabError error) => {
            Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}");

So in the playstream monitor I get this event:

in my unity console I get this log:

"function askChat called null results"

also the objects of the player I'm changing are still empty I think I'm expecting them to change:

thanks in advance for any help.

I have being asking quite a few questions I'm sorry for that. I'm kinda lost I'm not sure if I have being going around through the right track to learn how to use play-fab. I'm hoping I'm like just 1 question away from not needing more help thanks for all the help so far.

gpigd.png (15.1 KiB)
thqmp.png (59.2 KiB)
10 |1200

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

1 Answer

cartellonegerardo avatar image
cartellonegerardo answered

I think i found the answer to my own question in another question.

Type:"title_player_account", needs to be changed to Type:"master_player_account"

also the TypeString property is not really needed I just removed it and it worked.

More details here.

10 |1200

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

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.