Upload certificate: Using Asset API

Introduction:

This document describes how to upload certificate & use asset API’s for certificate

Background:

Jira Issue https://project-sunbird.atlassian.net/browse/SH-1228?

Problem Statement:

  1. How to upload certificate using asset API

Key design problems:

  1. How to get a certificate using asset API(deprecate the existing preference API)

  2. How to get default certificate layouts using asset API?

  3. How to upload/create new certificate template using certificate layout(asset) or existing certificate template?

Attaching cert to a batch(till R3.3.0):

The below code is used to attach certificate to a batch(without using asset API)

{ "identifier": "template_01_preprod_001", "criteria": { "enrollment": { "status": 2 } }, "name": "Course completion certificate", "issuer": { "name": "Gujarat Council of Educational Research and Training", "url": "https://gcert.gujarat.gov.in/gcert/" }, "signatoryList": [ { "image": "https://cdn.pixabay.com/photo/2014/11/09/08/06/signature-523237__340.jpg", "name": "CEO Gujarat", "id": "CEO", "designation": "CEO" } ], "notifyTemplate": { "subject": "Completion certificate", "stateImgUrl": "https://sunbirddev.blob.core.windows.net/orgemailtemplate/img/File-0128212938260643843.png", "regardsperson": "Chairperson", "regards": "Minister of Gujarat", "emailTemplateType": "defaultCertTemp" } }

How to get certificates using asset API


To get all the certificate templates or layouts use the search API call with filters certType & channel

 

“certType”:

Description

“certType”:

Description

“cert template”

to get all the actual certificate templates that can attach to a batch

“cert template layout”

to get all the certificate template layouts that can be used to create a new certificate template

“channel”: is used in the filter to get the certificate templates/layouts specific to channel

API endpoint:

POST: /api/content/v1/search

API request body:

{ "request": { "filters":{ "certType": "cert template", "channel": "in.ekstep" }, "fields": ["indentifier","name","code","certType","data","issuer","signatoryList","artifactUrl","primaryCategory","channel"], "limit": 100 } }

Response :

Curl:

How to get default certificate layouts using asset API?


Same as API search API with only change "certType": ”cert template layout”.

 

How to upload/create a new certificate template using a certificate layout(asset) or existing certificate template?


Create API (logo/signature create to get do_Id)

API endpoint:

API request:

API response:

Curl:

 

Upload API (logo/signature upload to blob storage to get artifactUrl)

API endpoint:

API request:

API response:

Curl:

 

How to upload/create an asset(used for uploading logos, signatures)


Create API (logo/signature create to get do_Id)

 

Upload Image

Primary Category

Description

Upload Image

Primary Category

Description

Logos

Asset

Publicly accessible to any user.

Signature

CertAsset

To avoid showing these images in any other asset browsers. These images should be private. Laster release we will use as “base64” string instead of uploading to blob.

API endpoint:

API request:

API response:

Curl:

 

Upload API (logo/signature upload to blob storage to get artifactUrl)

API endpoint:

API request:

API response:

Curl:

How to copy & use the existing certificate template


API endpoint:

API request:

API response:

 

How to get asset details(for do_id)


This is to get the details of the asset/certificate by using do_id
API endpoint:

API response:

Curl:

 

Related articles:

Certificate: Attach to a batch

https://project-sunbird.atlassian.net/wiki/spaces/SP/pages/1665925124/Certificate+criteria+verification?focusedCommentId=1679982648