【发布时间】:2019-10-10 12:02:07
【问题描述】:
当我尝试获取此 url 的文本(整个字符串)(例如)时,我收到此错误“HTTP 重定向请求失败”:“https://apic-desktop.musixmatch.com/ws/1.1/macro.subtitles.get?format=json&q_track=Mi%20Mi%20Mi%20%28Radio%20Edit%29&q_artist=SEREBRO&user_language=en&subtitle_format=mxm&app_id=web-desktop-app-v1.0&usertoken=SECRET TOKEN”但它在 chrome 中工作,我必须得到那个 json 文件https://pastebin.com/GJdLK3BA(我把它上传到 Pastebin)
平台:UWP x64 系统:Windows 10 pro 4 月更新
public string URLToString(string url)
{
HttpClient client = new HttpClient();
HttpResponseMessage response = client.GetAsync(url).Result;
string result = null;
if (response.IsSuccessStatusCode)
{
result = client.GetStringAsync(url).Result;
}
else
{
result = null;
}
return result;
}
LyURL = "https://apic-desktop.musixmatch.com/ws/1.1/matcher.lyrics.get?format=json&q_track=" + Uri.EscapeUriString(Title.Text) + "&q_artist=" + Uri.EscapeUriString(Arti.Text) + "&user_language=en&subtitle_format=mxm&app_id=web-desktop-app- v1.0&usertoken=*SECRET TOKEN*";
JObject jObject = JObject.Parse(URLToString(LyURL));
String Lyra = (string)jObject.SelectToken("message.body.lyrics.lyrics_body");
错误信息:HTTP 重定向请求失败
【问题讨论】:
标签: c# url redirect uwp http-redirect