We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesWallet KitRESTAPIs Called by Your ServerAPIs for Creating, Querying, and Modifying a PassAPIs of Other PassesQuerying a Pass Instance

Querying a Pass Instance

Function

Obtains a pass instance based on instanceId.

Scenario

This API is used to obtain a pass instance that has been added to the Huawei server.

Restrictions

You need to create an app in AppGallery Connect and apply for services corresponding to the passes.

Prototype

Protocol

HTTPS GET

Direction

Developer server -> Huawei server

URL

{url}/hmspass/v2/{cardType}/instance/{instanceId}

Set the {url} variable based on the region where the server is located. For details, please refer to Wallet Server Addresses.

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

URL Parameters

Expand

Parameter

Mandatory/Optional

Type

Description

cardType

Mandatory

String

Pass type. Set this parameter as required. For supported pass types, please refer to Other Passes Supported.

instanceId

Mandatory

String

Unique identifier of an instance. It must be unique across all instances sharing the same appId. The value contains only letters, digits, dots (.), hyphens (-), and underscores (_).

Request Parameters

Request Header

Expand

Parameter

Mandatory/Optional

Type

Description

Authorization

Mandatory

String

Authorization code. For details about how to obtain the value, please refer to the Client Credentials mode in OAuth 2.0-based Authentication. In this mode, client_id and client_secret are respectively the App ID and App key of the app that you created in AppGallery Connect. Concatenate the value of access_token to the end of Bearer, with a space in between, to generate the value of Authorization.

Content-Type

Mandatory

String

The value is always application/json;charset=utf-8.

Accept

Mandatory

String

The value is always application/json;charset=utf-8.

Request Example

Collapse
Word wrap
Dark theme
Copy code
  1. GET /hmspass/v2/key_parkcard/instance/70001 HTTP/1.1
  2. Content-Type: application/json;charset=utf-8
  3. Authorization: Bearer ***
  4. Accept: application/json;charset=utf-8
  5. Host: wallet-passentrust-drcn.cloud.huawei.com.cn

Response Parameters

When the result code is 200:

Expand

Parameter

Type

Description

For details, please refer to the HwWalletObject Parameters.

HwWalletObject

Pass instance that is identified by instanceId.

Response Example

Collapse
Word wrap
Dark theme
Copy code
  1. HTTP/1.1 200 OK
  2. Content-Type: application/json
  3. {
  4. "organizationPassId": "5623489234",
  5. "passTypeIdentifier": "hwpass.type.parkcard.test",
  6. "passStyleIdentifier": "class_parkcard_Test",
  7. "serialNumber": "70001",
  8. "fields": {
  9. "status": {
  10. "state": "active",
  11. "effectTime": "2019-11-13T00:00:00.111Z",
  12. "expireTime": "2020-11-20T00:00:00.111Z"
  13. },
  14. "barCode": {
  15. "text": "562348969211212",
  16. "type": "codabar",
  17. "value": "562348969211212",
  18. "encoding": "UTF-8"
  19. },
  20. "commonFields": [
  21. {
  22. "key": "cardNumber",
  23. "value": "12345678"
  24. "label": "cardNumber"
  25. }
  26. ],
  27. "appendFields": [
  28. {
  29. "key": "isCreateWhiteCard",
  30. "value": "true",
  31. "label": "NFCCardFlag"
  32. }
  33. ]
  34. }
  35. }

Result Codes

For details, please refer to Result Codes.

Call Example

Collapse
Word wrap
Dark theme
Copy code
  1. public HwWalletObject getWalletModelByModelId(String url, String modelId) {
  2. // Construct the HTTP header.
  3. HttpHeaders header = constructHttpHeaders();
  4. // Construct the HTTP URL.
  5. String baseUrl = ConfigHelper.instants().getValue("walletServerBaseUrl");
  6. String walletServerUrl = baseUrl + url + modelId;
  7. // Send the HTTP request and obtain the response.
  8. ResponseEntity<HwWalletObject> response =
  9. REST_TEMPLATE.exchange(walletServerUrl, HttpMethod.GET, new HttpEntity(header), HwWalletObject.class);
  10. // Return the wallet model with the corresponding model ID.
  11. return response.getBody();
  12. }
Search in References
Enter a keyword.