
# 查询DID
#### 功能介绍
查询指定DID的文档
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=BCS&api=ShowDID)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### URI
POST /v1/identity/query-did
#### 请求参数
表1请求Body参数 
| 参数           | 是否必选 | 参数类型   | 描述                     |
|:---|:---|:---|:---|
| orgID        | 是    | String | 组织id                   |
| channelID    | 是    | String | 通道id                   |
| cryptoMethod | 是    | String | 加密方法，目前固定为SW           |
| cert         | 是    | String | 用户证书，每行末尾均需要增加显式换行符\\n |
| sk           | 是    | String | 用户私钥，每行末尾均需要增加显式换行符\\n |
| timestamp    | 是    | String | 时间戳                    |
| did          | 是    | String | 分布式身份标识                |
   
#### 响应参数
**状态码： 200**
表2响应Body参数 
| 参数             | 参数类型                                                               | 描述              |
|:---|:---|:---|
| context        | String                                                             | context         |
| id             | String                                                             | 分布式身份标识         |
| publicKey      | Array of [DocPublicKey] objects | 公钥列表            |
| authentication | Array of strings                                                   | did主公钥标识        |
| recovery       | String                                                             | 备用公钥标识，可用于修改主密钥 |
| service        | Array of [Service] objects           | 服务列表            |
| proof          | [Proof] object                         | 证明结构，可为空        |
| created        | String                                                             | 创建时间            |
| updated        | String                                                             | 更新时间            |
| status         | String                                                             | 状态              |
   
 表3DocPublicKey 
| 参数           | 参数类型   | 描述       |
|:---|:---|:---|
| id           | String | 公钥标识     |
| type         | String | 公钥类型     |
| controller   | String | 公钥的控制者标识 |
| publicKeyPem | String | 公钥证书     |
   
 表4Service 
| 参数                    | 参数类型                                                                       | 描述              |
|:---|:---|:---|
| id                    | String                                                                     | 服务标识            |
| type                  | String                                                                     | 服务类型            |
| serviceEndpoint       | String                                                                     | 服务介绍网址          |
| credentialApplySchema | [CredentialApplySchema] object | 申请凭证所需数据的Schema |
   
 表5CredentialApplySchema 
| 参数          | 参数类型                                                         | 描述   |
|:---|:---|:---|
| type        | String                                                       | 类型   |
| name        | String                                                       | 名称   |
| description | String                                                       | 描述信息 |
| attributes  | Array of [Attribute] objects | 属性列表 |
   
 表6Attribute 
| 参数          | 参数类型   | 描述   |
|:---|:---|:---|
| name        | String | 名称   |
| type        | String | 类型   |
| description | String | 描述信息 |
   
 表7Proof 
| 参数             | 参数类型   | 描述      |
|:---|:---|:---|
| creator        | String | 创建者身份标识 |
| type           | String | 签名类型    |
| created        | String | 签名创建时间  |
| signatureValue | String | 签名值     |
   
**状态码： 500**
表8响应Body参数 
| 参数        | 参数类型   | 描述                           |
|:---|:---|:---|
| errorCode | String | 错误码 最小长度：**8** 最大长度：**36**   |
| errorMsg  | String | 错误描述 最小长度：**2** 最大长度：**512** |
   
#### 请求示例
```
{
  "orgID" : "4f1439758ebb41f7411b5f684b67713c08b89198",
  "channelID" : "mychannel",
  "cryptoMethod" : "SW",
  "cert" : "-----BEGIN CERTIFICATE-----\n...\n...\n-----END CERTIFICATE-----",
  "sk" : "------BEGIN PRIVATE KEY-----\n...\n...\n-----END PRIVATE KEY-----",
  "timestamp" : "2020-10-27T17:28:16+08:00",
  "did" : "did:example:ebfeb1f712ebc6f1c276e12ec21"
}
```
#### 响应示例
**状态码： 200**
分布式身份文档结构体
```
{
  "context" : "https://www.w3.org/ns/did/v1",
  "id" : "did:example:ebfeb1f712ebc6f1c276e12ec21",
  "publicKey" : [ {
    "id" : "string",
    "type" : "string",
    "controller" : "string",
    "publicKeyPem" : "string"
  } ],
  "authentication" : [ "did:example:ebfeb1f712ebc6f1c276e12ec21#key-0" ],
  "recovery" : "string",
  "service" : [ {
    "id" : "did:example:ebfeb1f712ebc6f1c276e12ec21#xdi",
    "type" : "XdiService",
    "serviceEndpoint" : "https://xdi.example.com/8377464",
    "credentialApplySchema" : {
      "type" : "LegalCitizen",
      "name" : "LegalCitizen",
      "description" : "Certified Chinese citizens",
      "attributes" : [ {
        "name" : "name",
        "type" : "someType",
        "description" : "Identity number"
      } ]
    }
  } ],
  "proof" : {
    "creator" : "did:example:ebfeb1f712ebc6f1c276e12ec21",
    "type" : "RsaSignature2018",
    "created" : "1606720551",
    "signatureValue" : "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0I      PAYuNzVBAh4vGHSrQyHUdBBPM"
  },
  "created" : "1588921521",
  "updated" : "",
  "status" : "active"
}
```
**状态码： 500**
失败响应
```
{
  "errorCode" : "BCS.5002034",
  "errorMsg" : "request timed out or been cancelled"
}
```
#### 状态码
| 状态码 | 描述         |
|:---|:---|
| 200 | 分布式身份文档结构体 |
| 500 | 失败响应       |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/devg-bcs/ErrorCode.html)。
