Developers
paul_harrington
—
2015-08-02T19:52:15-04:00 —
#1
Hi,
I am having problems with some of the API calls returning null and I cannot see what is the different between the ones that work and the ones that do not.
I am using the c# SDK and this call returns data:
public void GetListOfPlayers()
{
Players.Clear();
dynamic players = plCode.get("/runtime/players", new Dictionary<string, string>() { { "player_id", "tester1" } });
foreach (var p in players["data"])
{
Players.Add(new Player { Name = p["alias"], PlayerId = p["id"] });
}
}
However in the following code actions is null. Using "fiddler" I can see that the requested data is returned. I just can't figure out why it is not in the "actions" variable. No exceptions are thrown.
public void GetListOfActions()
{
try
{
dynamic actions = plCode.get(
route: "/runtime/actions",
query: new Dictionary<string, string>() { { "player_id", "tester1" } });
}
catch (Exception)
{
throw;
}
}
TIA
peter_john
—
2015-08-03T02:42:55-04:00 —
#2
It seems the SimpleJson.DeserializeObject(response.Content) is returning null because it can't deserialize arrays into dynamic. So that had to be changed to a <List<dynamic>>
to deserialize arrays. So I added another option to deserialize arrays just pass list: true and that should return a list to you
var player_id = new Dictionary<string, string> (){ { "player_id", "tester1" } };
List<dynamic> actions = pl.get(route: "/runtime/actions", query: player_id, list: true);
Console.WriteLine (actions[0]);
So please download this version of the sdk and try it out https://www.nuget.org/packages/playlyfe/0.5.1
Thank You for finding the bug, I wonder how the others overcame this maybe they used their own deserializers
paul_harrington
—
2015-08-10T18:59:23-04:00 —
#3
OK. Thanks that has resolved the issue.