question

willwhittaker avatar image
willwhittaker asked

Having trouble with CloudScript

I have a UI where I can build a ship by selecting the hull and then selecting all appropriate modifications that I want to put on it. Everything is great until I get to the part where I save it to PlayFab. I'm not sure what I'm doing wrong. Here's the code: http://pastebin.com/1masGwKc

If someone can point out what it is that I'm doing wrong here, that would be great. I'm a bit rusty on JS so I'm oblivious right now.

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.

1 Answer

·
brendan avatar image
brendan answered

Can you try JSON.stringify() on your data (the Value you're passing into the call to UpdateUserData)? User Data key/value pairs are specifically string/string.

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.

willwhittaker avatar image willwhittaker commented ·

In CloudScript, I changed it to this:

server.UpdateUserData({ "PlayFabId": currentPlayerId, "KeysToRemove": keys, "Data": JSON.stringify(theData) });

No luck :\

0 Likes 0 ·
willwhittaker avatar image willwhittaker commented ·

I should also mention that the "results.FunctionResult" from the ExecuteCloudScript call doesn't return anything either, it comes back to Unity as "Null".

0 Likes 0 ·
brendan avatar image brendan willwhittaker commented ·

I'm not sure what your expected inputs are - can you try calling the handler from the Game Manager? Just select a player account, click "Run Cloudscript", enter the parameters as you would expect them to be sent, and click run? The debug output on the right should give you more insight into the specifics of the error.

0 Likes 0 ·
willwhittaker avatar image willwhittaker commented ·

I figured it out. I had a small spelling error with the function names. As I mentioned I'm rusty on JS so even the standard JS API calls are eluding me sometimes. I had: new Date().GetTime() instead of: new Date().getTime().

Also you were right about using JSON.stringify, but I used it on the wrong object. I needed to use it on the "data" object that was being placed in the KeyValuePair value string. Not the KeyValuePair object itself.

0 Likes 0 ·
brendan avatar image brendan willwhittaker commented ·

Correct - that's what I meant by using it on the Value you were passing into the Key/Value pair. Glad to hear you're unblocked!

0 Likes 0 ·

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.