主页文档代码示例API 参考公告模型发行说明常见问题GitHub视频
开发者中心API 状态支持
文档
开发者中心API 状态支持

响应格式

SP-API 如何返回响应标头和消息。

在响应 HTTP 请求时,销售伙伴 API 会返回若干响应标头和一条 JSON 响应消息。

下表列出了您可能收到的响应标头。实际收到的标头取决于特定的 API 部分和操作。

响应标头

名称 描述 示例
连接 默认值 keep-alive,用于与客户端保持连接。 Connection: keep-alive
Content-Length 标准 HTTP 响应标头。 Content-Length: 624
Content-Type 标准 HTTP 响应标头。 Content-Type: application/json
日期 标准 HTTP 响应标头。 Date: Fri, 17 Feb 2023 20:13:55 GMT
x-amz-apigw-id 由 ApiGateWay 创建的扩展请求 ID。此标头是可选的,可能无法返回。 x-amz-apigw-id: Ac1E1EycvHcFyNw=
x-amzn-ErrorType 如果响应状态码为 4xx 或 5xx,ApigateWay 会用 errorType 填充此错误。此标头是可选的,可能无法返回。 x-amzn-ErrorType: AccessDeniedException
x-amzn-RateLimit-Limit Returns the rate limit applied to the request. This header is returned on a best-effort basis and only for specific HTTP responses. Refer to Usage Plans and Rate Limits in the SP-API for more information. x-amzn-RateLimit-Limit: 2.0
x-amzn-RequestId 请求标识符。如果您联系我们寻求支持,请提供此信息。 x-amzn-RequestId: 6875f61f-6aa1-11e8-98c6-9bExample
X-Amzn-Trace-Id 由 ApiGateWay 生成的追踪标识符。此标头是可选的,可能无法返回。 X-Amzn-Trace-Id: Root=1-63ee9bb8-52ea8e6d108209842abc2a4d

成功响应

`如果您的请求成功,销售伙伴 API 将返回请求的数据。以下是成功响应的示例:

HTTP/1.1 200 OK Content-Length: 368 Content-Type: application/json Date: Thu, 01 Jun 2020 22:23:31 GMT x-amzn-RequestId: 6875f61f-6aa1-11e8-98c6-9bExample { "payload": { "ConfirmedNeedByDate": "2020-04-23", "ConfirmedFulfillableDate": "2020-04-23" } }

错误响应

如果您的请求不成功,销售伙伴 API 将返回错误响应。以下是错误响应中响应消息的元素:

响应消息

元素描述必填项
codeHTTP 状态码。有帮助
message错误条件的说明。有帮助
details其他信息的链接。没有帮助

以下是错误响应的示例:

HTTP/1.1 400 Bad Request Content-Length: 117 Content-Type: application/json Date: Fri, 01 Jun 2020 21:48:02 GMT x-amzn-ErrorType: ValidationException x-amzn-RequestId: a8c8d99a-6ab5-11e8-b0f8-19363980175b { "errors": [ { "message": "Access to requested resource is denied.", "code": "Unauthorized", "details": "Access token is missing in the request header." } ] }

此页面对您有帮助吗?