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 Andrew Burrow · Aug 13, 2019 at 04:00 PM · CloudScriptLeaderboards and Statisticssdks

Returning linked account info from cloud script

I have a cloud script that returns 3 leaderboards with one api call. This works fine and I can deserialize it to 3 seperate GetLeaderboardResult objects. The problem occurs when I include a ProfileConstraints with ShowLinkedAccounts set to true. I get the result back fine but get the following error trying to deserialize it :

InvalidCastException: Invalid cast from 'System.String' to 'System.Nullable`1[[PlayFab.ClientModels.LoginIdentityProvider, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]'

Any help is greatly appreciated.

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 Citrus Yan · Aug 14, 2019 at 08:50 AM

Hi Andrew, I managed to reproduce your issue that InvalidCastException occurs when trying to deserialize CloudScript result with linked account returned. The method I used to deserialize was PlayFabSimpleJson.DeserializeObject, I suspect that you are using it too. However, when I tried to deserialize using PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject, it worked out well. The code is like this:

GetLeaderboardResult getLeaderboardResults = PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject<GetLeaderboardResult>(result.FunctionResult.ToString());

If this is your case, you could try the code below to see if it works. If this is not your case, could you please tell us what SDK are you using and share the code which you are using to deserialize.

Comment

People who like this

0 Show 4 · 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 Andrew Burrow · Aug 14, 2019 at 11:57 AM 0
Share

Thanks for that. Was hoping it wasn't something I was doing as everything looked ok. In the mean time I am just making 3 calls with the client API so I can get on. Would be nice to have a solution though to help cut down on calls. Thanks again.

avatar image Citrus Yan ♦ Andrew Burrow · Aug 15, 2019 at 02:55 AM 0
Share

Hi Andrew, correct me if I am wrong, as far as I am aware, you have to make 3 calls in order to get each leaderboard results so it’s better to directly call them from the client. What I don’t follow is that why you use Cloud Script to return 3 leaderboards. In the Cloud Script, you still need to call GetLeaderboard 3 times, serialize ExecuteCloudScriptResult and then deserialize it into GetLeaderboardResult in your client, which will definitely increase some overhead. Therefore, I think the better way is just making 3 calls from the client, which is the way you are doing now.

avatar image Andrew Burrow Citrus Yan ♦ · Aug 15, 2019 at 08:25 AM 0
Share

I am new to Playfab to you could be right, but they try to steer you towards using CloudScript as much as possible so I was under the hope/belief that calling CloudScript was only 1 API call as opposed to 3. I know there is a limit of 20 (I think) separate calls that can be made in that one CloudScript call, so maybe I have got that wrong. Could do with some clirification on that.

Show more comments

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

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Email Templates variables 1 Answer

    Unity: player has not played this title? 1 Answer

    Leaderboard reset at custom time 1 Answer

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

    Leaderboard amount limitations & dynamic creation? 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