【发布时间】:2017-03-30 22:36:19
【问题描述】:
我正在尝试使用以下代码连接到 Sabre API:
Dim u As String = "https://developer.sabre.com/io-docs/call-api"
' Create the web request
request2 = DirectCast(WebRequest.Create(u), HttpWebRequest)
' Get response
response2 = DirectCast(request2.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader2 = New StreamReader(response2.GetResponseStream())
' Console application output
' MsgBox(reader.ReadToEnd())
Response.Write(reader.ReadToEnd())
但是我收到以下错误:
“/”应用程序中的服务器错误。
远程服务器返回错误:(400) Bad Request。
说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详情:System.Net.WebException:远程服务器返回错误:(400) Bad Request。
来源错误:
第 49 行:
第 50 行:'获取响应
第 51 行:response2 = DirectCast(request2.GetResponse(), HttpWebResponse)
第 52 行:
第 53 行:'将响应流获取到阅读器中
【问题讨论】:
-
你能分享一下你想要完成什么吗?因为如果我访问 URL:developer.sabre.com/io-docs/call-api。 -> 我得到:“您的表单提交有问题。”
-
我想调用一个 api 我使用它的链接,当我在线测试 api 时它给我的链接
-
我也尝试并更改了我的代码仍然是相同的结果我只是想要一种调用 api 的方法它不必像我的代码一样