Paypal nvp api - 发布请求不起作用
我一直在阅读 API 并查看示例,他们似乎使用 POST 来发送请求。当我尝试使用 POST 时,我不断收到 10001 错误。当我将请求方法切换为 GET 时,它就起作用了。
我使用以下代码来发布请求 - 失败
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "Post";
req.ContentType = "application/x-www-form-urlencoded";
WebResponse response = req.GetResponse();
我使用完全相同的代码来使用 GET,但方法类型除外 - 有效
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "Get";
req.ContentType = "application/x-www-form-urlencoded";
WebResponse response = req.GetResponse();
我可以使用 GET 来发出 API 请求吗?我之所以问这个问题,是因为网上的每个示例都使用 POST,并且在他们的 API 示例中也使用了 POST。即使发送到 ssl 链接,使用 GET 是否存在某种安全风险?
最后,为什么 POST 请求发回无效响应?
I've been reading through the API and looking at samples and they seem to use POST to send their request. When I tried using POST I kept getting back a 10001 error. When I switched the request method to GET it works.
I was using the following code for Posting the request - FAILS
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "Post";
req.ContentType = "application/x-www-form-urlencoded";
WebResponse response = req.GetResponse();
I use the exact same code for using GET, except for method type - WORKS
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "Get";
req.ContentType = "application/x-www-form-urlencoded";
WebResponse response = req.GetResponse();
Can I use GET for making API requests? The reason I ask is because every single example on the net uses POST, and it is used in their API examples as well. Is there some sort of security risk of using GET even though it is sent to an ssl link?
Lastly, why is the POST request sending back an invalid response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论