6. 创建CPT

调用接口:

标题描述
接口名weid/api/invoke
MethodPOST
Content-Typeapplication/json

接口入参:

KeyValueRequired
functionNameregisterCptY
functionArg Y
functionArg.cptJsonSchemaCPT Json Schema,与 SDK直接调用的方式入参 一致,下同Y
functionArg.weIdCPT创建者Y
transactionArg Y
transactionArg.invokerWeId用于索引私钥的WeIdentity DID,服务器端会凭此找到所托管的私钥Y
v版本号Y
  1. CPT Json Schema是什么?应该满足什么格式?
  2.  
  3. 答:Json Schema是一种用来定义Json字符串格式的Json字符串,它定义了CPT应包括的字段、属性及规则。
  4. WeIdentity可以接受 http://json-schema.org/draft-04/schema# 所定义第四版及之前版本作为入参。

接口入参示例:

  1. {
  2. "functionArg": {
  3. "weId": "did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3",
  4. "cptJsonSchema":{
  5. "title": "cpt",
  6. "description": "this is cpt",
  7. "properties": {
  8. "name": {
  9. "type": "string",
  10. "description": "the name of certificate owner"
  11. },
  12. "gender": {
  13. "enum": [
  14. "F",
  15. "M"
  16. ],
  17. "type": "string",
  18. "description": "the gender of certificate owner"
  19. },
  20. "age": {
  21. "type": "number",
  22. "description": "the age of certificate owner"
  23. }
  24. },
  25. "required": [
  26. "name",
  27. "age"
  28. ]
  29. }
  30. },
  31. "transactionArg": {
  32. "invokerWeId": "did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3"
  33. },
  34. "functionName": "registerCpt"
  35. "v": "1.0.0"
  36. }

接口返回: application/json

KeyValue
ErrorCode错误码,0表示成功
ErrorMessage错误信息
respBodycptBaseInfo

返回示例:

  1. {
  2. "respBody": {
  3. "cptId": 10,
  4. "cptVersion": 1
  5. },
  6. "ErrorCode": 0,
  7. "ErrorMessage": "success"
  8. }