目录

Function

This API is used to query all configured attachments in a beacon.

Scenario

This API is called to query all configured attachments in a beacon.

Prototype

Protocol

HTTPS POST

Direction

App server or app -> HUAWEI Nearby Service server

URL

https://{Domain name}/WiseCloudNearbyBeaconService/v1/queryBeaconAttachment/{beaconId}?projectId=[projectId]

Data Format

Content-type: application/json

For details about how to obtain the domain name and projectID, please refer to API Call Process.

Restrictions

Input Parameters

Parameter

Mandatory(M)/Optional(O)

Type

Description

timeStamp

M

Long

Timestamp in the request header.

srcTranID

M

String

Transaction ID in the request header. The value contains a maximum of 24 characters.

Authorization

M

String

Parameter in the request header, which is used for gateway authentication. For details about how to obtain the JSON Web Token (JWT) of the parameter , please refer to Service Account-based Authentication.

projectId

O

String

Project ID for query. 

beaconId

M

String

Beacon ID in the URL.

Output Parameters

If the request is successful, status code 200 is returned with a response body containing the following parameters.

Parameter

Type

Description

attachments

Json object

Attachment structure list. For details, please refer to the following definition of the Attachment structure.

Attachment structure definition:

  1. {
  2. "namespace": "namespace002",
  3. "attachmentId": "202001191739115580278122214157680128",
  4. "type": "4",
  5. "value": "5oiR5piv5Lit5Zu95Lq6qw"
  6. }

Parameter

Type

Description

attachmentId

String

Attachment ID, which is automatically generated by the system during attachment configuration.

namespace

String

Namespace of an attachment.

type

String

Message type, which is customized and contains a maximum of 16 characters.

value

String

Attachment content, which is a Base64-encoded character string.

If the request fails, a status code other than 200 is returned with the following response body:

(1) A non-service request fails due to an exception (for example, the gateway verification fails or the token expires).

Parameter

Type

Description

error

String

Error message that is not returned by the service.

(2) A service request fails.

Parameter

Type

Description

serviceError

object

Error message that is returned by the service.

The JSON structure of serviceError is as follows.

Parameter

Type

Description

code

int

Result code. For details, please refer to the following result code table.

status

String

Error status.

message

String

Error description.

Result Code

Result Code

Description

Suggestion

400000001

Incorrect parameter in the request header.

Verify the request header parameter.

400000009

The beacon is not activated.

Activate the beacon.

403000003

The service account is unavailable.

Verify that the service account is available on the console of HUAWEI Developer.

403000004

You have no permission to perform operations on the beacon.

Verify that you have permission to perform operations the beacon using the service account.

404000006

The beacon does not exist.

Verify that the beacon exists.

500000001

Internal service error.

Contact Huawei technical support.

Example

Use an expired Authorization parameter to call the API. An error response body is returned.

Request:

  1. POST /WiseCloudNearbyBeaconService/v1/queryBeaconAttachment/bea001?projectId=id123 HTTP/1.1
  2. Host: Domain name.
  3. Cache-Control: no-cache
  4. Content-Type: application/json
  5. srcTranId: 201910181908046224775032
  6. timeStamp: 1579423534
  7. Accept: application/json
  8. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

Response:

  1. HTTP/1.1 401
  2. Content-type: application/json
  3. content-length: 27
  4. {error:"session timeout"}

The service request fails, and an error response body is returned, for example, the attachment list of a beacon that does not exist is queried.

Request:

  1. POST /WiseCloudNearbyBeaconService/v1/queryBeaconAttachment/bea001?projectId=id123 HTTP/1.1
  2. Host: Domain name.
  3. Cache-Control: no-cache
  4. Content-Type: application/json
  5. srcTranId: 201910181908046224775037
  6. timeStamp: 1579423534
  7. Accept: application/json
  8. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

Response:

  1. HTTP/1.1 404
  2. Content-type: application/json
  3. content-length: 113
  4. {"serviceError":{"code":404000006,"message":"The beacon with ID bea001 does not exist.","status":"Not Found"}}

The request is successful, and a success response body is returned.

Request:

  1. POST /WiseCloudNearbyBeaconService/v1/queryBeaconAttachment/beacon001?projectId=id123 HTTP/1.1
  2. Host: Domain name.
  3. Cache-Control: no-cache
  4. Content-Type: application/json
  5. srcTranId: 201910181908046224775031
  6. timeStamp: 1579423534
  7. Accept: application/json
  8. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

Response:

  1. HTTP/1.1 200
  2. content-length: 78
  3. Content-Type: application/json;charset=UTF-8
  4. {"attachments":[{"namespace":"namespace002","attachmentId":"202001191739115580278122214157680128","type":"4","value":"5oiR5piv5Lit5Zu95Lq6qw"}]}