尝试连接到 Saber 时出现错误 (400) 错误请求 API

Error (400) Bad Request when attempting to connect to Sabre API

我正在尝试使用以下代码连接到 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())

但是我收到以下错误:

Server Error in '/' Application.

The remote server returned an error: (400) Bad Request.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.

Source Error:

Line 49:
Line 50: ' Get response
Line 51: response2 = DirectCast(request2.GetResponse(), HttpWebResponse)
Line 52:
Line 53: ' Get the response stream into a reader

您没有引用正确的 Sabre API 端点。我建议查看 .Net Saber API 代码示例以获取参考信息。

https://github.com/SabreDevStudio/SACS-DotNet

我建议您学习 REST 基础知识:https://developer.sabre.com/docs/rest_basics

这里有不同的环境 URL、如何创建会话以及如何开始使用 REST API,同样适用于 SOAP API。

如何实际调用每项服务的过程将取决于语言,因为您似乎在使用 VB.NET 这里您有 2 个我找到的指南。

  1. 在 .NET 中使用 REST 服务 (Microsoft.com)
    https://msdn.microsoft.com/en-us/library/jj819168.aspx

  2. 从 C# 或 VB 应用程序 (Codeproject.com) 使用 Json Web 服务
    https://www.codeproject.com/Articles/233698/Consuming-a-Json-WebService-from-a-Csharp-or-VB-Ap