6. 创建CPT
调用接口:
标题 | 描述 |
---|---|
接口名 | weid/api/invoke |
Method | POST |
Content-Type | application/json |
接口入参:
Key | Value | Required |
---|---|---|
functionName | registerCpt | Y |
functionArg | Y | |
functionArg.cptJsonSchema | CPT Json Schema,与 SDK直接调用的方式入参 一致,下同 | Y |
functionArg.weId | CPT创建者 | Y |
transactionArg | Y | |
transactionArg.invokerWeId | 用于索引私钥的WeIdentity DID,服务器端会凭此找到所托管的私钥 | Y |
v | 版本号 | Y |
- CPT Json Schema是什么?应该满足什么格式?
- 答:Json Schema是一种用来定义Json字符串格式的Json字符串,它定义了CPT应包括的字段、属性及规则。
- WeIdentity可以接受 http://json-schema.org/draft-04/schema# 所定义第四版及之前版本作为入参。
接口入参示例:
- {
- "functionArg": {
- "weId": "did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3",
- "cptJsonSchema":{
- "title": "cpt",
- "description": "this is cpt",
- "properties": {
- "name": {
- "type": "string",
- "description": "the name of certificate owner"
- },
- "gender": {
- "enum": [
- "F",
- "M"
- ],
- "type": "string",
- "description": "the gender of certificate owner"
- },
- "age": {
- "type": "number",
- "description": "the age of certificate owner"
- }
- },
- "required": [
- "name",
- "age"
- ]
- }
- },
- "transactionArg": {
- "invokerWeId": "did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3"
- },
- "functionName": "registerCpt",
- "v": "1.0.0"
- }
接口返回: application/json
Key | Value |
---|---|
ErrorCode | 错误码,0表示成功 |
ErrorMessage | 错误信息 |
respBody | cptBaseInfo |
返回示例:
- {
- "respBody": {
- "cptId": 10,
- "cptVersion": 1
- },
- "ErrorCode": 0,
- "ErrorMessage": "success"
- }