问题是 ToBase64string 中的字符串“resulted”在调试时正在转换,但是当我在编码后使用 result 时,似乎在我想在编码后使用“resulted”的“var response =”中,它不基于调试模式进行编码。为什么?我错过了什么吗
[HttpGet, Route("values/get")]
public async Task<string> Get(string resulted)
{
//resulted.Remove(0, 17);
string res = "";
using (var client = new HttpClient())
{
// HTTP POST
client.BaseAddress = new Uri("https://api.elliemae.com/");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(resulted)));
var response = client.GetAsync("/encompass/v1/loans/{ea7c29a6-ee08-4816-99d2-fbcc7d15731d}?Authorization=Bearer "+resulted+"&Content-Type=application/json").Result;
using (HttpContent content = response.Content)
{
// ... Read the string.
Task<string> result = content.ReadAsStringAsync();
res = result.Result;
}
}
return res;
}