错误代码和异常
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
API 错误响应
下表介绍了 Google Wallet API 可能会返回的错误代码、可能的原因以及解决方案。
异常 |
示例消息 |
建议 |
400 - BadRequestException |
请求中包含无效的参数。资源 ID 无效:{1234567891234567899 - ABCD1234567}。 |
检查数据结构的类型、格式和长度,并传递正确的参数。 |
403 - PermissionDeniedException |
权限遭拒 |
确保在 Business Pay 和钱包控制台内是正确的服务账号电子邮件地址是授权用户。 |
404 - NotFoundException |
找不到电子钱包对象 {1234567891234567899.SampleClubCardxf6a8edf-87ca-4022-a813-694cc57e9fd3}。 |
先对对象 ID 执行 GET,然后再尝试发出 PATCH 或 PUT 请求,以确保您有一个对象要更新的对象,并且该对象是最新的对象。 |
404 - IssuerClassNotFoundException |
找不到电子钱包对象类 {1234567891234567899.ABCD.1234567}。 |
执行更新时,请确保在执行 PATCH 或 PUT 请求之前执行 GET 请求,以确保您有一个类来引用它是最新类。此外,还要确保请求中正确使用了正确的负载(对象和类)。 |
409 - AlreadyExistsException |
钱包对象类 {1234567891234567899.ABCD.1234567} 已存在。 |
请先对类 ID 执行 GET,然后再尝试创建相同的类 ID。如果资源存在,您可能需要使用 PATCH 或 PUT.。 |
基于 Web 的错误消息
如果您尝试使用“添加到 Google 钱包”链接保存卡券时发生错误,系统会显示一条信息性错误消息,帮助您进行调试。这些消息只会向对关联的发卡机构帐号拥有“开发者”或“管理员”角色的用户显示。
以下是可能显示的错误消息类型的示例:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eThis page explains the different error codes that may be returned by the Google Wallet API, including BadRequestException, PermissionDeniedException, NotFoundException, IssuerClassNotFoundException, and AlreadyExistsException.\u003c/p\u003e\n"],["\u003cp\u003eEach error code has an explanation for the possible causes and suggestions for how to resolve the issue.\u003c/p\u003e\n"],["\u003cp\u003eThe table provides example messages for each exception, and links to relevant documentation for further troubleshooting.\u003c/p\u003e\n"],["\u003cp\u003eWeb-based error messages are shown to users with 'Developer' or 'Admin' roles when saving a pass using the 'Add to Google Wallet' link to assist with debugging.\u003c/p\u003e\n"],["\u003cp\u003eThese informative error messages provide detailed information about the issue, helping users identify and resolve problems quickly.\u003c/p\u003e\n"]]],["The Google Wallet API returns specific error codes: 400 (BadRequestException) indicates an invalid argument, requiring checks on data structure. 403 (PermissionDeniedException) means the service account lacks authorization. 404 (NotFoundException) signals a missing Wallet Object or Class, needing a GET request before PATCH/PUT actions. 409 (AlreadyExistsException) indicates an existing class, suggesting a GET request and potential PATCH/PUT instead of creating it again. Web errors are displayed to developers and admins.\n"],null,["# Error codes and exceptions\n\nAPI error responses\n-------------------\n\nThe following table explains error codes that mayn be returned by the Google Wallet API, their possible causes, and solutions.\n\n| Exception | Example Message | Suggestion |\n|------------------------------------|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 400 - BadRequestException | Request contains an invalid argument. Invalid resource ID: {1234567891234567899 - ABCD1234567}. | Check the data structure for type, format and length and pass the correct argument. |\n| 403 - PermissionDeniedException | Permission Denied | Ensure the correct [Service Account](https://developers.google.com/wallet/retail/loyalty-cards/web/prerequisites#4.-authorize-the-service-account) email is an authorized user within your Business Pay and Wallet Console. |\n| 404 - NotFoundException | Wallet Object {1234567891234567899.SampleClubCardxf6a8edf-87ca-4022-a813-694cc57e9fd3} not found. | Perform a [GET](https://developers.google.com/wallet/generic/rest/v1/genericclass/get#http-request) on the Object ID before trying before a [PATCH](https://developers.google.com/wallet/generic/rest/v1/genericclass/patch#http-request) or [PUT](https://developers.google.com/wallet/generic/rest/v1/genericclass/update#http-request) request to ensure you have an object to update and that it's the latest. |\n| 404 - IssuerClassNotFoundException | Wallet Object Class {1234567891234567899.ABCD.1234567} not found. | When performing an update , ensure you do a [GET](https://developers.google.com/wallet/generic/rest/v1/genericclass/get#http-request) request before a [PATCH](https://developers.google.com/wallet/generic/rest/v1/genericclass/patch#http-request) or [PUT](https://developers.google.com/wallet/generic/rest/v1/genericclass/update#http-request) request to ensure you have a class to reference that it's the latest class. Also ensure the correct payload (object and class) is being used in the request correctly. |\n| 409 - AlreadyExistsException | Wallet Object Class {1234567891234567899.ABCD.1234567} already exists. | Perform a [GET](https://developers.google.com/wallet/generic/rest/v1/genericclass/get#http-request) on the Class ID before trying to create the same Class ID. If the resource exists you may want to use [PATCH](https://developers.google.com/wallet/generic/rest/v1/genericclass/patch#http-request) or [PUT.](https://developers.google.com/wallet/generic/rest/v1/genericclass/update#http-request) |\n\nWeb-based error messages\n------------------------\n\nIf something goes wrong when you attempt to save a pass using an 'Add to Google Wallet' link, you will be shown an informative error message to help you debug. These messages are only shown to users that have the 'Developer' or 'Admin' role for the associated Issuer account.\n\nHere is an example of the type of error message that might be displayed:"]]