I trying to Post to this api: https://api.golike.net:9998/api/job . And print the result api give back
Type json of that api is:
{"user":`{"id":37,"username":"lucky","counter_rechecking":0,"user_id":761,"fb_id":"100047460285611"}}
Can anyone help me. there is already data and type data. Thanks For Help. You can help me post using HttpRequest or HttpClient
Check this
private static async Task<HttpResponseMessage> Post(string uri, object input)
{
var content = new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, "application/json");
var client = new HttpClient
{
BaseAddress = new Uri(YourBaseApiAddress)
};
var response = await client.PostAsync(uri, content);
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
var newResponse = await Post(uri, input, Authentication);
return newResponse;
}
return response;
}
and for your response
var response = Post(uri, yourObject).Result;
if (response.IsSuccessStatusCode)
{
var value = await response.Content.ReadAsStringAsync();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.