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 Ricardo Chavarria · Feb 21, 2018 at 05:19 AM ·

CloudScript UpdateUserReadOnlyData Error

Hi,

I'm getting an error when updating `UserReadOnlyData` from CloudScript

{
    "api": "/Server/UpdateUserReadOnlyData",
    "request": {
        "PlayFabId": "94CBFE4872721A3B",
        "Data": {
            "FirstSessionDate": "02/21/2018 05:06:27"
        }
    },
    "result": null,
    "apiError": {
        "code": 400,
        "status": "BadRequest",
        "error": "InvalidParams",
        "errorCode": 1000,
        "errorMessage": "Invalid input parameters",
        "errorHash": null,
        "errorDetails": {
            "Data": [
                "The value for key FirstSessionDate was not valid JSON."
            ]
        }
    }
}

This is the same code I'm using in all my previous titles, which should work for this title as well (589A).

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

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Ricardo Chavarria · Feb 23, 2018 at 03:47 AM

Ok, so the answer is, there IS something different with other titles, and that's the Settings > API panel has this option: Require valid JSON for custom data values.

This option must have been added as default on for new titles, because it was OFF for old titles and ON for this new one.


We'll have to check our procedures and see what is not valid JSON, but turning this OFF fixed our problems for now.


screen-shot-2018-02-22-at-104136-pm.png (45.9 kB)
Comment
Ricardo Chavarria

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
avatar image

Answer by Brendan · Feb 21, 2018 at 06:56 AM

Sorry, but can you clarify how you're making this call specifically? Having the code snippet showing the actual Cloud Script would help.

Comment

People who like this

0 Show 6 · 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 Ricardo Chavarria · Feb 21, 2018 at 03:10 PM 0
Share

Here's the code:

function SetReadOnlyData(data)
{
    var request = {
        "PlayFabId": currentPlayerId,
        "Data": data
    };


    var result = server.UpdateUserReadOnlyData(request);
    var dataVersion = result.DataVersion;
    var readonlyData = server.GetUserReadOnlyData({"PlayFabId": currentPlayerId});


    var response = {
        "DataVersion": dataVersion,
        "ReadOnlyData": readonlyData.Data
    };


    return response;
}

Which is called from here:

handlers.onAccountCreation = function(args)
{
    var firstSessionDate = args.firstSessionDate;

...

    // Readonly data
    if (firstSessionDate != null)
    {
        var data = {
            "FirstSessionDate": firstSessionDate
        };


        response["ReadOnlyData"] = SetReadOnlyData(data);
    }


...



}
avatar image Joshua Strunk · Feb 21, 2018 at 08:22 PM 0
Share

Can you add a log before you make the request which prints out the value of the data object you are trying to set?

As the first line of your SetReadOnlyData function

log.info(JSON.stringify(data))
avatar image Ricardo Chavarria Joshua Strunk · Feb 21, 2018 at 09:04 PM 0
Share

Will do. It just seems a bit weird that this exact code is working on our other titles and not this one.

avatar image Ricardo Chavarria Joshua Strunk · Feb 21, 2018 at 09:11 PM 0
Share

This is from one of our other titles, a user created yesterday. I don't get why the same code would behave differently in this title.

screen-shot-2018-02-21-at-40629-pm.png (26.4 kB)
avatar image Joshua Strunk Ricardo Chavarria · Feb 21, 2018 at 09:44 PM 0
Share

Yea I am not sure but my guess is that in this case FirstSessionDate is not actually a string or it is a weird string trigging some edge case? It is hard to tell without the log

Show more comments
avatar image

Answer by Ricardo Chavarria · Feb 22, 2018 at 04:48 AM

I still don't see the problem. This being used exactly the same in our production-titles, it makes little sense.

"Logs": [
            {
                "Level": "Info",
                "Message": "{\"FirstSessionDate\":\"02/22/2018 04:39:13\"}",
                "Data": null
            },
            {
                "Level": "Error",
                "Message": "PlayFab API request error",
                "Data": {
                    "api": "/Server/UpdateUserReadOnlyData",
                    "request": {
                        "PlayFabId": "94CBFE4872721A3B",
                        "Data": {
                            "FirstSessionDate": "02/22/2018 04:39:13"
                        }
                    },
                    "result": null,
                    "apiError": {
                        "code": 400,
                        "status": "BadRequest",
                        "error": "InvalidParams",
                        "errorCode": 1000,
                        "errorMessage": "Invalid input parameters",
                        "errorHash": null,
                        "errorDetails": {
                            "Data": [
                                "The value for key FirstSessionDate was not valid JSON."
                            ]
                        }
                    }
                }
            }
        ],
Comment

People who like this

0 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

    2 People are following this question.

    avatar image avatar image

    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