question

adrienbarisic avatar image
adrienbarisic asked

Update Player Statistics on Javascript Play fab SDK returns an error of null end point API

Major problems in javascript playfab sdk , The login seems to work fine but updating Player statistics return an error where play sdk tries to reach a null api

This s the code I used to update the player statistics ,

PlayFabClientSDK.titleId = '2CB76' varSubmitScoreRequest = { StatisticName:'HighScore', Value:200,
}
PlayFabClientSDK.UpdatePlayerStatistics(SubmitScoreRequest, this.ScoreSubmitted) }


Please note that login is working fine , Getting leaderboards is working fine , But trying to update player statistics is giving an error , I am going to use cloud scripting to update the statstic for now until this is fixed

Code I am using for updating statistics

here is the exact error that is being gernerated

POSThttps://null.playfabapi.com/Client/UpdatePlayerStatistics?sdk=JavaScriptSDK-1.90.210816[HTTP/2 400 Bad Request 298ms]

Here's some debug information: The URL for this request is not valid for this title. The correct API endpoint is https://2cb76.playfabapi.com/ GameScene.js:601:20 Uncaught (in promise) Object { code: 400, status: "BadRequest", error: "InvalidAPIEndpoint", errorCode: 1131, errorMessage: "The URL for this request is not valid for this title. The correct API endpoint is https://2cb76.playfabapi.com/", CallBackTimeMS: 602, Request: {…}, CustomData: undefined }




Player Datasdks
2 comments
10 |1200

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

adrienbarisic avatar image adrienbarisic commented ·

I tried udpating the statistics using cloud script too unfotunately same result , I even tried to include Title id in the request but still same result

0 Likes 0 ·
adrienbarisic avatar image adrienbarisic commented ·

I did this two calls back to back leaderboard successfully fetches but other call returns null api end point error

PlayFabClientSDK.titleId = '2CB76' // game.PlayFab.settings.titleId = '2CB76' varLeaderboardRequest = { StatisticName :'HighScore', StartPosition :0, MaxResultCount :20 }
console.log(PlayFabClientSDK.GetLeaderboard(LeaderboardRequest,this.GetLeaderBoardResult))
PlayFabClientSDK.titleId = '2CB76' // PlayFab.ClientApi.titleId = '2CB76'
varSubmitScoreRequest= { Statistics: { StatisticUpdate:{ StatisticName :'HighScore', Value:400 } }[1] };

PlayFabClientSDK.UpdatePlayerStatistics(SubmitScoreRequest, this.ScoreSubmittedHere)

0 Likes 0 ·
Gosen Gao avatar image
Gosen Gao answered

According to the API definition, you should set your Title Id to PlayFab.settings.titleId.

if(!PlayFab.settings) {
    PlayFab.settings = {
        titleId: null, // You must set this value for PlayFabSdk to work properly (Found in the Game Manager for your title, at the PlayFab Website)
        developerSecretKey: null, // For security reasons you must never expose this value to the client or players - You must set this value for Server-APIs to work properly (Found in the Game Manager for your title, at the PlayFab Website)
        GlobalHeaderInjection: null,
        productionServerUrl: ".playfabapi.com"
    }
}

By the way, the request of UpdatePlayerStatistic should be like this.

request = {
    Statistics : [
        {
            StatisticName : "HighScore",
            Value : 200
        }
    ]
}

10 |1200

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

adrienbarisic avatar image
adrienbarisic answered

Hi thank you so much for quick response I had a deadline today my post was in moderation for sometime I figured it out during the night thank you so much for your quick response that was actually the issue I was having last night and I was able to figure out what was wrong although I wonder why the login request went through ?

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.