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

Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.

HMS Core ReferencesNearby ServiceRESTful APIs of BeaconUpdating a Beacon Attribute

Updating a Beacon Attribute

Function

This API is used to update a beacon attribute.

Scenario

This API is called to update a beacon attribute.

Prototype

Protocol

HTTPS PUT

Direction

App server or app -> HUAWEI Nearby Service server

URL

https://{Domain name}/WiseCloudNearbyBeaconService/v1/updateBeaconInfo?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

Expand

Parameter

Mandatory(M)/Optional (O)

Type

Description

srcTranID

M

String

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

timeStamp

M

Long

Timestamp in the request header.

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 toService Account-based Authentication.

projectId

O

String

Project ID for query.

beacon

M

object

Beacon information in the request body. For details, please refer to beacon Structure.

Output Parameters

If the request is successful, status code 200 is returned without a response body.

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.

400000002

Incorrect parameter in the request body.

Verify the request body 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 using the current account.

Ensure that the account has the operation permission.

404000006

The beacon does not exist.

Check whether the beacon has been registered. If not, register it.

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:

Collapse
Word wrap
Dark theme
Copy code
  1. PUT /WiseCloudNearbyBeaconService/v1/updateBeaconInfo?projectId=id123 HTTP/1.1
  2. PUT data: {"beacon":{"beaconId":"aa123","beaconType":1,"beaconDesc":"iBeacon_73548ada","latitude":90.0,"longitude":180.0,"indoorLevel":"0","properties":"{\"key1\":\"value1\",\"key2\":\"value2\"}"}}
  3. Host: Domain name.
  4. Content-Type: application/json
  5. srcTranId: 201910181908046224775031
  6. timeStamp: 922337203685477580
  7. Accept: application/json
  8. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

Response:

Collapse
Word wrap
Dark theme
Copy code
  1. HTTP/1.1 401 Unauthorized
  2. Content-type: application/json
  3. content-length: 27
  4. {"error":"session timeout"}

The request fails, and an error response body is returned, for example, the attribute of a deactivated beacon is updated.

Request:

Collapse
Word wrap
Dark theme
Copy code
  1. PUT /WiseCloudNearbyBeaconService/v1/updateBeaconInfo?projectId=id123 HTTP/1.1
  2. PUT data: {"beacon":{"beaconId":"aabb123","beaconType":1,"beaconDesc":"iBeacon_test","latitude":81.0,"longitude":180.0,"indoorLevel":"0","properties":"{\"key1\":\"value1\",\"key2\":\"value2\"}"}}
  3. Host: Domain name.
  4. Content-Type: application/json
  5. srcTranId: 201910181908046224775031
  6. timeStamp: 922337203685477580
  7. Accept: application/json
  8. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

Response:

Collapse
Word wrap
Dark theme
Copy code
  1. HTTP/1.1 400 Bad Request
  2. Content-type: application/json
  3. content-length: 96
  4. {"serviceError":{"code":400000009,"message":"The beacon is not active.","status":"Bad Request"}}

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

Request:

Collapse
Word wrap
Dark theme
Copy code
  1. PUT /WiseCloudNearbyBeaconService/v1/updateBeaconInfo?projectId=id123 HTTP/1.1
  2. PUT data: {"beacon":{"beaconId":"aabb124","beaconType":1,"beaconDesc":"iBeacon_test","latitude":81.0,"longitude":180.0,"indoorLevel":"0","properties":"{\"key1\":\"value1\",\"key2\":\"value2\"}"}}
  3. Host: Domain name.
  4. Content-Type: application/json
  5. srcTranId: 201910181908046224775031
  6. timeStamp: 922337203685477580
  7. Accept: application/json
  8. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

Response:

Collapse
Word wrap
Dark theme
Copy code
  1. HTTP/1.1 200 OK
  2. Content-type: application/json
  3. content-length: 0


This page may contain third-party content. For details, click here.
Search in References
Enter a keyword.