question

Canberk Soner avatar image
Canberk Soner asked

ExecuteCloudScriptServerRequest and Player ID

I need to call a cloudscript function from server API, but when I do not pass a player ID as a parameter, I receive a BadRequest error. The problem is, as a server, I'm not necessarily running a cloudscript function on behalf of a player.

There are some stuff that I need to do with my server cloudscript calls (I've implemented some simple checks to prevent normal clients from calling these methods) which are not linked to a specific player.

As a workaround I can just supply a random player ID since I'm not using it, but this doesn't "feel" correct.

Is there any way to just call a cloudscript function with whatever arguments I want? I couldn't see any similar api request in admin api.

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

·
Andy avatar image
Andy answered

Try out ExecuteEntityCloudScript. With that, you do not need to pass in a specific entity key. Include a title auth token (obtained from GetEntityToken) in the headers and the cloud script will run in the context of the title entity instead of a specific player.

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.

Canberk Soner avatar image Canberk Soner commented ·

Thanks Andy. I think this is not directly included in Unity SDK yet, but I can just use it as a regular web API call.

0 Likes 0 ·
Andy avatar image Andy ♦♦ Canberk Soner commented ·

You're free to do it from a web call, but it's absolutely in the latest Unity SDK (and has been since about September, I believe): https://github.com/PlayFab/UnitySDK/blob/master/Source/PlayFabSDK/CloudScript/PlayFabCloudScriptAPI.cs#L32

You might need to enable the Entity API in the editor extension before you can use it, though.

1 Like 1 ·

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.