Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Muhammad Roshaan Tariq · Mar 11, 2020 at 08:41 AM · apisCloudScriptsdksentities

Cloudscript returning NULL in Response

Hi,

I have used CloudScript for integrating Clan/Group System in my game. All Clans/Group functions are implemented on server side and I am using ExecuteCloudScript on client side to call these functions.

What I really want is that the CloudScript should return some proper response but what I get is just NULL (Please check screenshot I have attached)

here's my cloudcode:

handlers.joinGroup = function(args,context){
  var addMemberToGroup = {
      "Group":{
          "Id": args.groupID
      },
      "Members":[{
          "Id": args.userID,
          "Type": "title_player_account",
          "TypeString": "title_player_account"
      }],
      "RoleId": args.roleID
  };
  
  var response = entity.AddMembers(addMemberToGroup);
  return response;
};

and here's what I get in response

Now you see even though the cloudscript ran the function successfully but I didn't get a proper response to identify whether the function was a success or failure.

sharedscreenshot.jpg (45.5 kB)
Comment
Roshaan

People who like this

1 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Mar 12, 2020 at 06:31 AM

API AddMembers or RemoveMembers would not return any data when it is requested successfully, but you can catch its error when it is called failed. Doing error handling on the clients and on CloudScript are both feasible. Please follow this documentation SDK error handling best practices if you want to handle errors on clients. If you want to get a “Success” string or error messages from the CloudScript function result, please try to add the following code in the function.

handlers.leaveGroupGenerateError = function (args, context) {
    var removeGroupMember = {
        "Group": {
            "Id": args.groupID
        },
        "Members": [{
            "Id": args.userID,
            "Type": "title_player_account",
            "TypeString": "title_player_account"
        }]
    };
    try {
        var response = entity.RemoveMembers(removeGroupMember);
    } catch (ex) {
        let errorMessage = ex.apiErrorInfo.apiError.errorMessage;
        return errorMessage;
    }
    return "Success";
}

Comment

People who like this

0 Show 3 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Muhammad Roshaan Tariq · Mar 12, 2020 at 08:51 AM 0
Share

@Sarah Zhang

And what about in the case of AddMembers? Does it also returns the NULL or Empty string in response?

avatar image Sarah Zhang ♦ Muhammad Roshaan Tariq · Mar 13, 2020 at 03:00 AM 0
Share

Yes, it's an omission, I have modified the answer to add it.

In addition, you can test every PlayFab API on your own too. PlayFab provides the SDK for Postman which is an external REST API testing tool. This is one of the fastest ways to get started testing PlayFab. You can test the API via Postman before you call it on CloudScript, you can also test the CloudScript functions via API ExecuteEntityCloudScript and ExecuteCloudScript in the Postman.

avatar image Muhammad Roshaan Tariq Muhammad Roshaan Tariq · Mar 13, 2020 at 11:10 AM 0
Share

@Sarah Zhang

Alright, thanks for clearing this up because I was trying to find why there isn't anything returning from the API when I run it using cloudscript.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    How to check if User is part of a group at the same time when using ListMembership function 2 Answers

    Sending Telemetry events from Server 1 Answer

    How to edit Entity Access Policy? 2 Answers

    UserData object different between client and server? 1 Answer

    Cloud Script Entities. Get title objects of player 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges