简体   繁体   中英

Getting 403 Forbidden for the same request to server in second time

I using HttpClient object make an http call to retrieve audio content of file. Somehow same request works for first time but when i seek the content and make the new request with same set of headers i am getting 403 Forbidden error.

I just don't understand what exactly causing the error. I tried to set User-agent in DefaultRequestHeaders but nothing is working.

await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);

Response Header ContentType = application/vnd.apple.mpegurl Set-Cookie = some value

Please suggest me what could be wrong

Try clearing the HTTP client headers. I faced the same problem, then cleared the HTTP client headers and it worked.

httpClient.DefaultRequestHeaders.Clear();

before sending the request should solve the problem.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM