0

I try to get data from a Gamesparks LogEventRequest in Unity, but the ScriptData of the response object is always null... I can't see the problem because the cloud code works fine in the test harness. I get a correct response. Only in Unity I can't get the data.

So this is my cloud code (this works fine in the test harness):

GET_PLAYER Event


var query = API.S("playerId").eq(Spark.getPlayer().getPlayerId());

var resultOBJ = API.queryItems("playerData", query);

var cursor = resultOBJ.cursor();

var stories = "";

while(cursor.hasNext()){

     var req = new SparkRequests.GetUploadedRequest();
     var next = cursor.next();
     stories = next.getData().stories;

}

Spark.setScriptData("stories", stories);

My Code in Unity:

 new LogEventRequest()
            .SetEventKey("GET_PLAYER")
            .Send(response =>
            {
                Debug.Log(response.ScriptData.GetString("stories")); //is null
            });

When I try to get a value like:

response.ScriptData.GetString("stories")

I get this error:

{ "stories": "REQUIRED" }

Any ideas? Thanks in advance!

Funkberater
  • 775
  • 8
  • 16

1 Answers1

0

simply use

Debug.Log(response.ScriptData.JSON);
Uzair
  • 714
  • 2
  • 6
  • 17