-
-
Save hatelove/d7a3e95e7b0618496cdee5c603bb4979 to your computer and use it in GitHub Desktop.
use HttpClient Post to web service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetOtp(string accountId) | |
{ | |
var httpClient = new HttpClient() {BaseAddress = new Uri("http://joey.com/")}; | |
var response = httpClient.PostAsJsonAsync("api/otps", accountId).Result; | |
if (response.IsSuccessStatusCode) | |
{ | |
return response.Content.ReadAsAsync<string>().Result; | |
} | |
else | |
{ | |
throw new Exception($"web api error, accountId:{accountId}"); | |
} | |
} |
chingmiou
commented
May 4, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment