Please somebody help me, I tried to create a function for many hours now, I tried a lot of snippets and all, but im just confused how those functions work. Please no links to the ban/server apis, I saw all of them, I just dont understand it. I even watched hour long videos for azure functions, but no luck...
This code snippet looks easy, but I tried to put that in a azure function for hours now:
https://docs.microsoft.com/en-us/gaming/playfab/features/data/playerdata/player-bans
This is what I have (with a lot of wrong code, I know), I tried to cobine all snippets I found, googled error codes, but its not working:
public static class BanUserNow { [FunctionName("BanUserNow")] public static async Task<dynamic> BanUserNowOk([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { var context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync()); var args = context.FunctionArgument; var argsPlayerID = (string)args["profileID"] ?? string.Empty; var profileID = string.IsNullOrEmpty(argsPlayerID) ? context.CallerEntityProfile.Lineage.MasterPlayerAccountId : argsPlayerID; PlayFabServerAPI.BanUsersAsync(new BanUsersRequest() { Bans = new List<BanRequest>() { new BanRequest() { DurationInHours = 6, PlayFabId = profileID, Reason = "Automatic ban for WH", } } }); } } }