Authentication 接口验证访问 (C#)
private HttpClient _httpClient = new HttpClient();
private string PostToOwner(CarOwnerCoupon postData) { string url ="www.abcxxxx.com"; string base64Creds ="user" + ":" +"pwd"; _httpClient.BaseAddress = new Uri(url); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( "Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(base64Creds))); HttpContent content = new StringContent(JsonSerializer.Serialize(postData)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = _httpClient.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result; return result; }