use the generic method

This commit is contained in:
2018-10-21 17:46:03 +02:00
parent 5839626956
commit 0d670364b2

View File

@ -19,6 +19,14 @@ namespace testOauthClient.Controllers
{ {
ILogger _logger; ILogger _logger;
public class GCMRegistrationRecord {
public string GCMRegistrationId { get; set; } = "testGoogleRegistrationIdValue";
public string DeviceId { get; set; }= "TestDeviceId";
public string Model { get; set; }= "TestModel";
public string Platform { get; set; }= "External Web";
public string Version { get; set; }= "0.0.1-rc1";
}
public HomeController(ILoggerFactory loggerFactory) public HomeController(ILoggerFactory loggerFactory)
{ {
_logger=loggerFactory.CreateLogger<HomeController>(); _logger=loggerFactory.CreateLogger<HomeController>();
@ -100,7 +108,7 @@ namespace testOauthClient.Controllers
return View("Index", model: await response.Content.ReadAsStringAsync()); return View("Index", model: await response.Content.ReadAsStringAsync());
}*/ }*/
JsonValue result = null; GCMRegistrationRecord result = null;
var authHeader = $"Bearer {AccessToken}"; var authHeader = $"Bearer {AccessToken}";
_logger.LogWarning($"using authorization Header {authHeader}"); _logger.LogWarning($"using authorization Header {authHeader}");
try { try {
@ -109,8 +117,8 @@ namespace testOauthClient.Controllers
using (var request = new SimpleJsonPostMethod( using (var request = new SimpleJsonPostMethod(
"http://dev.pschneider.fr/api/gcm/register", authHeader)) "http://dev.pschneider.fr/api/gcm/register", authHeader))
{ {
result = await request.InvokeJson(new result = await request.Invoke<GCMRegistrationRecord>(new
{ GCMRegistrationRecord {
GCMRegistrationId = "testGoogleRegistrationIdValue", GCMRegistrationId = "testGoogleRegistrationIdValue",
DeviceId = "TestDeviceId", DeviceId = "TestDeviceId",
Model = "TestModel", Model = "TestModel",