public static string InsertHighScore(HighPointsModel playerScore) { try { using (client) { client.BaseAddress = new Uri(ApiAddress); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("User-Agent", "web api client"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; HttpResponseMessage response; try { response = client.PostAsJsonAsync("highpoints", playerScore).Result; } catch (System.Exception) { client.BaseAddress = new Uri(ApiAddressAlternative); response = client.PostAsJsonAsync("highpoints", playerScore).Result; } return(response.ToString()); } } catch (Exception ex) { return(ex.InnerException.ToString()); } }
public void SaveHighPointsToApi() { HighPointsModel model = new HighPointsModel() { Id = 999, PlayerID = SystemInfo.deviceUniqueIdentifier, HighPoints = guildPoints, Username = User.GetGlobalUsername() }; string response = ""; response = ApiConsumer.InsertHighScore(model); textResponse.text = response; Debug.Log(response); }