This API is used to register a beacon.
This API is called to register a beacon.
Protocol | HTTPS POST |
Direction | App server or app -> HUAWEI Nearby Service server |
URL | https://{Domain name}/WiseCloudNearbyBeaconService/v1/registerBeacon?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.
You need to obtain the service account credential. For details, please refer to Service Account-based Authentication.
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 to Service 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. |
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 | 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. |
403000003 | The service account is unavailable. | Verify that the service account is available on the console of HUAWEI Developer. |
409001001 | A maximum of 10,000 beacons can be created under a single sub-account. | Check the number of beacons created by the sub-account and delete discarded beacons. |
409001002 | The beacon record already exists. | Ensure that the beacon has not been registered. |
409001003 | The relationship between the beacon and the account already exists. | Ensure that the beacon has not been registered. |
500000001 | Internal service error. | Contact Huawei technical support. |
Request:
- POST /WiseCloudNearbyBeaconService/v1/registerBeacon?projectId=id123 HTTP/1.1
- POST data: {"beacon":{"beaconId":"aa123","beaconType":1,"beaconDesc":"iBeacon_73548ada","latitude":90.0,"longitude":180.0,"indoorLevel":"0","properties":"{\"key1\":\"value1\",\"key2\":\"value2\"}"}}
- Host: Domain name.
- Content-Type: application/json
- srcTranId: 201910181908046224775031
- timeStamp: 922337203685477580
- Accept: application/json
- Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
Response:
- HTTP/1.1 401 Unauthorized
- Content-type: application/json
- content-length: 27
- {"error":"session timeout"}
Request:
- POST /WiseCloudNearbyBeaconService/v1/registerBeacon?projectId=id123 HTTP/1.1
- POST data: {"beacon":{"beaconId":"aa123","beaconType":1,"beaconDesc":"iBeacon_73548ada","latitude":90.0,"longitude":180.0,"indoorLevel":"0","properties":"{\"key1\":\"value1\",\"key2\":\"value2\"}"}}
- Host: Domain name.
- Content-Type: application/json
- srcTranId: 201910181908046224775031
- timeStamp: 922337203685477580
- Accept: application/json
- Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
Response:
- HTTP/1.1 409 Conflict
- Content-type: application/json
- content-length: 102
- {"serviceError":{"code":409001002,"message":"The beacon ID has been registered.","status":"Conflict"}}
Request:
- POST /WiseCloudNearbyBeaconService/v1/registerBeacon?projectId=id123 HTTP/1.1
- POST data: {"beacon":{"beaconId":"aa124","beaconType":1,"beaconDesc":"iBeacon_73548ada","latitude":90.0,"longitude":180.0,"indoorLevel":"0","properties":"{\"key1\":\"value1\",\"key2\":\"value2\"}"}}
- Host: Domain name.
- Content-Type: application/json
- srcTranId: 201910181908046224775031
- timeStamp: 922337203685477580
- Accept: application/json
- Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
Response:
- HTTP/1.1 200 OK
- Content-type: application/json
- content-length: 0