public async Task <IdentityProviderUserModel> Create(NewUser newuser) { var authenticateUser = new AuthenticateIdentityProviderUser(); var token = authenticateUser.AuthAsync().GetAwaiter().GetResult(); string aUser = JsonConvert.SerializeObject(newuser); var buffer = System.Text.Encoding.UTF8.GetBytes(aUser); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token); Client.DefaultRequestHeaders.Add("cache-control", "no-cache"); Client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8"); var response = await Client.PostAsync($"https://dmiqa2.calastonetest.com/login/oauth/users/", byteContent); //read the body string responseBody = await response.Content.ReadAsStringAsync(); string body = response.Content.ToString(); return(user = parseUser(responseBody)); }