Help Center> ServiceStage> API Reference> ServiceComb API> Microservice> Querying the Unique Service or Schema ID of a Microservice
Updated on 2024-06-14 GMT+08:00

Querying the Unique Service or Schema ID of a Microservice

Function

This API is used to query the unique service or schema ID of a microservice based on filter criteria.

URI

GET /v4/{project_id}/registry/existence

Table 1 Path parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • For a professional microservice engine, enter the tenant project ID. The value contains 1 to 64 characters. See Obtaining a Project ID. You can also enter the fixed value default.
  • For an exclusive microservice engine, enter the fixed value default.
Table 2 Query parameters

Parameter

Mandatory

Type

Description

type

Yes

String

Request type.

  • microservice
  • schema
NOTE:
  • If type is set to microservice, env, appId, serviceName, and version are mandatory.
  • If type is set to schema, serviceId and schemaId are mandatory.

env

No

String

Microservice environment. Value: development, testing, acceptance, or production.

appId

Yes

String

Application ID, which needs to be transferred when the resource type is microservice. The value contains 1 to 160 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$

serviceName

Yes

String

Microservice name, which needs to be transferred when the resource type is microservice. The value contains 1 to 128 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$

version

Yes

String

Microservice version, which needs to be transferred when the resource type is microservice. The value contains 1 to 64 characters. Regular expression: ^[0-9]$|^[0-9]+(.[0-9]+)$

serviceId

Yes

String

Microservice ID, which needs to be transferred when the resource type is schema. The value contains 1 to 64 characters. Regular expression: ^.*$

schemaId

Yes

String

Schema ID, which needs to be transferred when the resource type is schema. The value contains 1 to 160 characters. Regular expression: ^[a-zA-Z0-9]{1,160}$|^[a-zA-Z0-9][a-zA-Z0-9_-.]{0,158}[a-zA-Z0-9]$.

Request

Table 3 Request header parameter

Parameter

Mandatory

Type

Description

Authorization

No

String

This parameter is mandatory if security authentication is enabled for an exclusive microservice engine. Otherwise, this parameter is not required.

The token of an exclusive microservice engine with security authentication enabled is in the following format:

Authorization:Bearer {Token}

For details about how to obtain the token, see Obtaining the User Token of an Exclusive Microservice Engine.

Response

Status code: 200

Table 4 Response header parameter

Parameter

Type

Description

X-Schema-Summary

String

Summary of a microservice schema.

Table 5 Response body parameters

Parameter

Type

Description

serviceId

String

When a service is queried, a service ID is returned.

schemaId

String

When a schema is queried, a schema ID is returned.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Example Request

Query serviceId based on microservice as type, default as appId, service as serviceName, and 1.0.0 as version.

GET https://{endpoint}/v4/{project_id}/registry/existence?type=microservice&appId=default&serviceName=service&version=1.0.0

Example Response

Status code: 200

Successfully queried. serviceId or schemaId is returned.

{
  "serviceId" : "8aed80ea052ac04a64dfc79c24f2170224d074f5"
}

Status Code

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Code

See ServiceComb Error Codes.