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 Konstantin Milev · Oct 07, 2019 at 04:16 AM · CloudScriptunity3ddata

Question: Reading data from player account

Hello,

I'm having an issue with CloudScript/Unity SDK

Basically I'm making a CloudScript function that's supposed to get data from player's account - in this case, a token (ex: 8jhxv9qk4isk1ckdrt0) which was previously generated and saved to the account. Here I'm supplying a PlayfabID to that account to get the saved token:

handlers.getRandomToken = function (args) {
    var playerData = server.GetUserReadOnlyData({"PlayFabId" : args.inputValue, "Data" : ["Token"]}); 
    var token = {};
    if(playerData.Data.hasOwnProperty("Token")) { token = playerData.Data["Token"]; }
    log.info(token);
    return { messageValue: token};
};

This token gets sent back to the client that called the method (from a callback), but the problem is that the "format" of token that is returned is not correct (contains other stuff): {"Value":"8jhxv9qk4isk1ckdrt0","LastUpdated":"2019-10-04T20:11:33.268Z","Permission":"Public"}
This is where I receive the result (token):

private void OnGetUserToken(ExecuteCloudScriptResult result)
    {
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        jsonResult.TryGetValue("messageValue", out object messageValue);
        UserToken = (string)messageValue;
        Debug.Log((string)messageValue);
        Debug.Log("OnGetUserToken token value set: " + (string)messageValue);
    }
I need the thing in "Value" but I don't know how to get it... Is there anything to do with serialization?

I'd appreciate any help!
Thanks in advance!
Comment

People who like this

0 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 Konstantin Milev · Oct 05, 2019 at 09:22 PM

I managed to fix the issue by using PlayFab.ISerializerPlugin which wasn't mentioned anywhere in the docs, I managed to find it by looking at other questions in this forum

Comment
Sarah Zhang

People who like this

1 Show 0 · 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

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

    1 Person is following this question.

    avatar image

    Related Questions

    SetFriendTags works for one player but not the other. 1 Answer

    Store Transform Data 0 Answers

    Updating internal user data fails on cloudscript no matter the formatting and can't update the SDK 2 Answers

    Update part of a JSON 1 Answer

    Nested Json data in Cloudscript 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