question

rlavoie avatar image
rlavoie asked

GetStoreItems throws JavascriptException in CloudScript

I'm trying to call the GetStoreItems from cloud script using:

let storeInfo = server.GetStoreItems({ "PlayFabId": currentPlayerId, "CatalogVersion": "Default", "StoreId": "ShopBux" })

or any permutation (but always keeping the required StoreId)

let storeInfo = server.GetStoreItems({ "CatalogVersion": "Default", "StoreId": "ShopBux" })
let storeInfo = server.GetStoreItems({ "StoreId": "ShopBux" })

but I keep getting a JavaScriptException with no more details

I know this call is fairly new, so maybe it is not working right, or am I doing something wrong?

P.S. The client version of this call does work.

CloudScript
10 |1200

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

brendan avatar image
brendan answered

Thanks for calling that out. The Cloud Script service is being updated now to enable the use of the new API call from scripts. We expect it'll be fully functional in script tomorrow (Friday).

5 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.

rlavoie avatar image rlavoie commented ·

Hi, I'm trying it out this morning. Still getting Javascript errors.

0 Likes 0 ·
franklinchen avatar image franklinchen rlavoie commented ·

Hi @rlavoie, I just got the update from team, the fix should be deployed tomorrow.

1 Like 1 ·
franklinchen avatar image franklinchen rlavoie commented ·

Hi @rlavoie, I just verified that the GetStoreItems sever API is available in cloudscript now.

1 Like 1 ·
franklinchen avatar image franklinchen rlavoie commented ·

Hi @rlavoie, thank you for your feedback, I can also repro this JavascriptException in our test title, I just informed the team to double check the root cause. Sorry for any inconverience caused.

0 Likes 0 ·
Show more comments
Citrus Yan avatar image
Citrus Yan answered

Hi,

I was able to reproduce your issue that server.GetStoreItems throws JavascriptException in CloudScript, in the StackTrace it says “TypeError: server.GetStoreItems is not a function\n at handlers.getStoreItems”. I will report this to our engineering team and keep you informed of any new updates, thanks for your feedback:)

10 |1200

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

kamyker avatar image
kamyker answered

You can use this as a workaround, edit your-title and your-key in the code:

function TempGetStoreItems(storeId: string): PlayFabServerModels.GetStoreItemsResult {
    let url = "https://your-title-id.playfabapi.com/Admin/GetStoreItems";
    let method = "POST";
    let contentBody = `{"StoreId": "${storeId}"}`;
    let contentType = "application/json";
    let headers = { "X-SecretKey": "your-key" };
    let responseString = http.request(url, method, contentBody, contentType, headers);
    let responseJSONObj: any = JSON.parse(responseString);
    return <PlayFabServerModels.GetStoreItemsResult>(responseJSONObj.data);
}
10 |1200

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

rlavoie avatar image
rlavoie answered

It is now working as intended. Thanks!

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.