GraphQL:授权 header 格式无效
GraphQL: Authorization header format invalidad
我正在尝试访问需要授权访问的 API。文档建议使用此测试 API Key 8626cf56-e364-4fd1-4fe0-311e23ac6355.
首先,我已经在 Postman 中设置了授权,就像您在这张图片中看到的那样:
而 headers 是:
但是,当我尝试在 Postman 中使用“POST”获取数据时,我得到了这个结果:
{
"error": {
"code": 480,
"type": "BAD_REQUEST",
"description": "Authorization header format invalid"
}
}
GraphQL 中的查询是:
query {
hotelX {
search(
criteria: {
checkIn: "2021-12-28",
checkOut: "2021-12-29",
occupancies: [{ paxes: [{age: 30}, {age: 30}] }],
hotels: ["1"],
currency: "EUR",
market: "ES",
language: "es",
nationality: "ES"
},
settings: {
client: "client_demo",
context: "HOTELTEST",
auditTransactions: false,
testMode: true,
timeout: 25000
},
filter: {
access: {
includes: ["0"]
}
}) {
context
errors{
code
type
description
}
warnings{
code
type
description
}
options {
id
accessCode
supplierCode
hotelCode
hotelName
boardCode
paymentType
status
occupancies {
id
paxes {
age
}
}
rooms {
occupancyRefId
code
description
refundable
roomPrice {
price {
currency
binding
net
gross
exchange {
currency
rate
}
}
breakdown {
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
rules {
id
name
type
value
}
}
}
}
}
beds {
type
count
}
ratePlans {
code
}
}
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
rules {
id
name
type
value
}
}
}
supplements {
code
name
description
supplementType
chargeType
mandatory
durationType
quantity
unit
resort {
code
name
description
}
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
}
}
}
surcharges {
chargeType
description
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
}
}
}
rateRules
cancelPolicy {
refundable
cancelPenalties {
hoursBefore
penaltyType
currency
value
}
}
remarks
}
}
}
}
我做错了什么?
您需要通过文档检查服务期望的确切格式,但您可能必须按以下格式发送 Authorization
header:
Authorization: ApiKey 8626cf56-e364-4fd1-4fe0-311e23ac6355
我认为这可能是基于错误消息的预期格式:
"error": {
"code": 480,
"type": "BAD_REQUEST",
"description": "Authorization header format invalid"
}
而且你没有发送任何 Authorization
header.
您可以像这样在 Postman 中设置 collection 级别:
{{apikey}}
指的是Postman中的一个环境变量。
我正在尝试访问需要授权访问的 API。文档建议使用此测试 API Key 8626cf56-e364-4fd1-4fe0-311e23ac6355.
首先,我已经在 Postman 中设置了授权,就像您在这张图片中看到的那样:
而 headers 是:
但是,当我尝试在 Postman 中使用“POST”获取数据时,我得到了这个结果:
{
"error": {
"code": 480,
"type": "BAD_REQUEST",
"description": "Authorization header format invalid"
}
}
GraphQL 中的查询是:
query {
hotelX {
search(
criteria: {
checkIn: "2021-12-28",
checkOut: "2021-12-29",
occupancies: [{ paxes: [{age: 30}, {age: 30}] }],
hotels: ["1"],
currency: "EUR",
market: "ES",
language: "es",
nationality: "ES"
},
settings: {
client: "client_demo",
context: "HOTELTEST",
auditTransactions: false,
testMode: true,
timeout: 25000
},
filter: {
access: {
includes: ["0"]
}
}) {
context
errors{
code
type
description
}
warnings{
code
type
description
}
options {
id
accessCode
supplierCode
hotelCode
hotelName
boardCode
paymentType
status
occupancies {
id
paxes {
age
}
}
rooms {
occupancyRefId
code
description
refundable
roomPrice {
price {
currency
binding
net
gross
exchange {
currency
rate
}
}
breakdown {
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
rules {
id
name
type
value
}
}
}
}
}
beds {
type
count
}
ratePlans {
code
}
}
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
rules {
id
name
type
value
}
}
}
supplements {
code
name
description
supplementType
chargeType
mandatory
durationType
quantity
unit
resort {
code
name
description
}
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
}
}
}
surcharges {
chargeType
description
price {
currency
binding
net
gross
exchange {
currency
rate
}
markups {
channel
currency
binding
net
gross
exchange {
currency
rate
}
}
}
}
rateRules
cancelPolicy {
refundable
cancelPenalties {
hoursBefore
penaltyType
currency
value
}
}
remarks
}
}
}
}
我做错了什么?
您需要通过文档检查服务期望的确切格式,但您可能必须按以下格式发送 Authorization
header:
Authorization: ApiKey 8626cf56-e364-4fd1-4fe0-311e23ac6355
我认为这可能是基于错误消息的预期格式:
"error": {
"code": 480,
"type": "BAD_REQUEST",
"description": "Authorization header format invalid"
}
而且你没有发送任何 Authorization
header.
您可以像这样在 Postman 中设置 collection 级别:
{{apikey}}
指的是Postman中的一个环境变量。