目录

Function

This API is used to query the namespace list of a user.

Scenario

This API is called after a project is created in HUAWEI Developer.

Prototype

Protocol

HTTPS GET

Direction

App server or app -> HUAWEI Nearby Service server

URL

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

You need to obtain the service account credential. For details, please refer to Service Account-based Authentication.

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 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

namespace

Json object

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

Namespace structure definition:

  1. {
  2. "visibility":"PRIVATE",
  3. "namespace":"dev9105385871708434"
  4. }

Parameter

Type

Description

visibility

String

Namespace visibility. The options are as follows:

PUBLIC

PRIVATE

namespace

String

Namespace.

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.

403000003

The service account is unavailable.

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


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. GET /WiseCloudNearbyBeaconService/v1/queryNamespace?projectId=id123 HTTP/1.1
  2. Host: Domain name.
  3. Content-Type: application/json
  4. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
  5. srcTranID: 202001141709412953357215
  6. timeStamp: 922337203685477580
  7. Accept: application/json

Response:

  1. HTTP/1.1 401
  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, an unauthorized account is used to call this API.

Request:

  1. GET /WiseCloudNearbyBeaconService/v1/queryNamespace?projectId=id123 HTTP/1.1
  2. Host: Domain name.
  3. Content-Type: application/json
  4. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
  5. srcTranID: 202001141709412953357215
  6. timeStamp: 922337203685477580
  7. Accept: application/json

Response:

  1. HTTP/1.1 403
  2. Content-Type: application/json
  3. Content-Length: 84
  4. {"serviceError":{"code":403000003,"message":"The service account is unavailable","status":"Forbidden"}}

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

Request:

  1. GET /WiseCloudNearbyBeaconService/v1/queryNamespace?projectId=id123 HTTP/1.1
  2. Host: Domain name.
  3. Content-Type: application/json
  4. Authorization: Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx
  5. srcTranID: 202001141709412953357215
  6. timeStamp: 922337203685477580
  7. Accept: application/json

Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. Content-Length: 61
  4. {"namespaces":[{"visibility":"PRIVATE","namespace":"dev9105385871708434"}]}