从URL检索数据时出错:响应状态代码不表示成功:999(请求被拒绝) [英] Getting error on retrieving data from a url: Response status code does not indicate success: 999 (Request denied)

查看:581
本文介绍了从URL检索数据时出错:响应状态代码不表示成功:999(请求被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过httpClient请求检索网址上的数据,但我收到"拒绝请求"错误。以下是代码。

I am trying to retrieve data on a url via httpClient request but I am getting "Request denied" error. Below is the code of it.

因此,在检索响应时,我收到请求被拒绝错误。在我的Request标题中是否需要更改任何内容?

So, while retrieving response I am getting request denied error. Is there anything I need to change in my Request header?

谢谢,

Yugank Narula

Yugank Narula

推荐答案

对于API提供商来说,这确实是一个问题。您收到的错误表明他们不喜欢您发送的内容。您应该验证您发送的数据以及他们的期望。请注意,您似乎试图模拟一个可能是
的浏览器,而不是您想要获取字节数组的操作。如果您正在尝试使用API​​,那么您将不会模拟浏览器。另请注意,您正在尝试读取字节数组,但如果您正在请求XML,那么它可能是文本,因此您应该读取字符串
或流,然后保存到文件中。
This is really a question for the API provider. The error you're getting indicates they didn't like what you sent them. You should verify the data you're sending and what they expect. Note that you appear to be trying to emulate a browser which is probably not what you want to do for getting a byte array. If you're trying to work with an API then you won't be emulating a browser. Also note that you're trying to read a byte array but if you're requesting XML then it'll likely be text so you should read as a string or stream and then save into a file.


这篇关于从URL检索数据时出错:响应状态代码不表示成功:999(请求被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆