登录Nike网站时持续出现403 Forbidden错误求助(附C#代码)
登录Nike网站遭遇403 Forbidden错误求助
我尝试登录Nike网站时,尽管登录凭证正确(出于安全考虑已替换示例账号密码,报错时所用凭证无误),却持续收到403 Forbidden错误。我推测操作存在问题但无法定位,附上相关C#请求代码,恳请技术帮助。
using System; using System.Text; using System.Threading.Tasks; namespace Project007 { public class Program { static async Task Main(string[] args) { LoginClient loginClient = new LoginClient(); await loginClient.Put(); while (true) { Console.ReadKey(); } } } public class LoginClient { private readonly HttpClient _client; public LoginClient() { _client = new HttpClient(); } public async Task Put() { using (var request = new HttpRequestMessage(HttpMethod.Post, $"https://accounts.nike.com/challenge/password/v1")) { request.Content = new StringContent("{credential: \"example@gmail.com\", password: \"example\"}", Encoding.UTF8, "application/json"); request.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"); using (var response = await _client.SendAsync(request)) { Console.WriteLine(response.StatusCode); } } } } }
内容的提问来源于stack exchange,提问作者hud Kad
相关产品推荐
相关产品推荐

