Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
{
  "id": "api.forum.v3.create",
  "ver": "1.0",
  "ets": 1614939498392,
  "params": {
    "resmsgid": "4739650a-cd23-43ce-9634-0e864d243eba",
    "msgid": "",
    "status": "Success"
  },
  "responseCode": "OK",
  "result": {
    "forums": [
      {
        "sbType": "95502931-e903-45e0-a4f7-f6ae3c97a66f",
        "sbIdentifier": "95502931-e903-45e0-a4f7-f6ae3c97a66f",
        "newCid": 93,
        "cids": [
          93
        ]
      }
    ]
  }
}

Postman Collection

Discussion Forum API's Postman collection

For courses:

Till now, a Discussion forum for courses can be configured via APIs only.

...

Code Block
{
    "code": "ok",
    "payload": {
        "cid": 7, // this cid will used as pid for the next et of apis
        "name": "Course: Parent category ",
        "description": "",
        "descriptionParsed": "",
        "icon": "",
        "bgColor": "#86C1B9",
        "color": "#333",
        "slug": "7/course-parent-category",
        "parentCid": 0,
        "topic_count": 0,
        "post_count": 0,
        "disabled": 0,
        "order": 7,
        "link": "",
        "numRecentReplies": 1,
        "class": "col-md-3 col-xs-6",
        "imageClass": "cover",
        "isSection": 0
    }
}

Step 2:
Call Take the above created CID and make the create forum API call for course:
Endpoint:

Code Block
POST: {{host}}/discussion/forum/v3/create

Request Body:

Code Block
{
  "category": {
    "name": "Discussion forum for course",
    "pid": "7", // parent category (take the cid form the above api response)
    "uid": "1", // admin user id
    "description": "",
    "context": [
      {
        "type": "course",
        "identifier": "_courseId" // to be replaced by actual Course_id
      }
    ],
    "privileges": {
      "copyFromCategory": "134" // dummy category with course level privileges
    },
  }
}

Response:

Code Block
{
  "subcategoriesid": ["api.forum.v3.create",
  "ver": "1.0",
   {"ets": 1614939498392,
  "params": {
    "nameresmsgid": "Annoucements4739650a-cd23-43ce-9634-0e864d243eba",
        "descriptionmsgid": "",
        "privilegesstatus": {"Success"
  },
       "copyFromCategoryresponseCode": "120OK",
// dummy category with batch level privileges (for anouncement)"result": {
          }
      },"forums": [
      {
        "namesbType": "General discussionscourse",
        "descriptionsbIdentifier": "do_1234",
        "privilegesnewCid": {
8,
         "copyFromCategorycids": [
 "121" // dummy category with batch level privileges (for GD)8
        }]
      }
    ]
  }
}

...

ResponseStep:

...

3

After creating course level category, we have to create batch level category. For the batch level also we are using same api (forum create).

End Point

Code Block
POST: {{host}}/discussion/forum/v3/create

Note: Take the newCid value from the above response.

Request Body

Code Block
{
  "idcategory": "api.forum.v3.create", {
    "vername": "1.0Discussion forum for Batch",
    "ets": 1614939498392,
  "params": {
    "resmsgid": "4739650a-cd23-43ce-9634-0e864d243eba",
    "msgid": "",
    "status": "Success"
  },
  "responseCode": "OK",
  "result": {
    "forums": [
      {
        "sbType": "do_1234",
        "sbIdentifier": "do_1234",pid": "8", // parent category (take the cid form the above api response)
    "uid": "1", // admin user id
    "description": "",
    "context": [
      {
        "type": "batch",
        "identifier": "_batchId" // to be replaced by actual batch_id
      }
    ],
    "privileges": {
      "copyFromCategory": "134" // dummy category with batch level privileges
    },
    "subcategories": [
      {
        "name": "Annoucements",
        "description": "",
        "privileges": {
          "copyFromCategory": "120" // dummy category with batch level privileges (for anouncement)
        }
      },
      {
        "name": "General discussions",
        "description": "",
        "privileges": {
          "copyFromCategory": "121" // dummy category with batch level privileges (for GD)
        }
      }
    ]
  }
}

Response

Code Block
{
  "id": "api.forum.v3.create",
  "ver": "1.0",
  "ets": 1614939498392,
  "params": {
    "resmsgid": "4739650a-cd23-43ce-9634-0e864d243eba",
    "msgid": "",
    "status": "Success"
  },
  "responseCode": "OK",
  "result": {
    "forums": [
      {
        "sbType": "batch",
        "sbIdentifier": "batchId",
        "newCid": 9,
        "cids": [
          9
        ]
      }
    ]
  }
}

Some Usfull Apis:

  1. Access the groups and group users attached to a category.

End Point

Code Block
{{host}}/discussions/api/forum/v3/groups/users

Request Body

Code Block
{
    "request": {
        "cid": 255,
        "groups": ["Course Mentor", "kvn_001"]  // optional
    }
}

Response

Code Block
{
    "id": ".api.forum.v3.groups.users",
    "ver": "1.0",
    "ets": 1615210872732,
    "params": {
        "resmsgid": "5c9755e2-9aeb-4efd-aae1-c347803bbe48",
        "msgid": "",
        "status": "Success"
    },
    "responseCode": "OK",
    "result": {
        "groups": [
            {
                "name": "Global Moderators",
                "members": []
            },
            {
                "name": "guests",
                "members": []
            },
            {
                "name": "spiders",
                "members": []
            },
            {
                "name": "registered-users",
                "members": [
                    {
                        "uid": 24,
                        "userName": "vvaanqqeeeqnuuydddy",
                        "sbUid": "1122311135656333w"
                    },
                    {
                        "uid": 9,
                        "userName": "venkat002",
                        "sbUid": "efgh_5678"
                    },
                    {
                        "uid": 8,
                        "userName": "venkat001",
                        "sbUid": "abcd_1234"
                    },
                    {
                        "uid": 7,
                        "userName": "ven1",
                        "sbUid": null
                    },
                    {
                        "uid": 6,
                        "userName": "venkat-group 0",
                        "sbUid": null
                    },
                    {
                        "uid": 5,
                        "userName": "venkat-test",
                        "sbUid": null
                    },
                    {
                        "uid": 4,
                        "userName": "testUser",
                        "sbUid": null
                    },
                    {
                        "uid": 3,
                        "userName": "Vinu",
                        "sbUid": null
                    },
                    {
                        "uid": 26,
                        "userName": "dsbfjdsf",
                        "sbUid": "45454646461112333"
                    },
                    {
                        "uid": 25,
                        "userName": "fsbmbgbfsgs",
                        "sbUid": "4545464646"
                    },
                    {
                        "uid": 23,
                        "userName": "vvaanqqeeeqnuuyy",
                        "sbUid": "112231113565633"
                    },
                    {
                        "uid": 22,
                        "userName": "vvaanqqeeeqn",
                        "sbUid": "11223111333"
                    },
                    {
                        "uid": 21,
                        "userName": "vvaanqqqn",
                        "sbUid": "112231113"
                    },
                    {
                        "uid": 2,
                        "userName": "venkat",
                        "sbUid": null
                    },
                    {
                        "uid": 17,
                        "userName": "test-venkat-22",
                        "sbUid": "abcd_12342222211q2332322222"
                    },
                    {
                        "uid": 16,
                        "userName": "test-venkat-2",
                        "sbUid": "abcd_12342222211q233232"
                    },
                    {
                        "uid": 15,
                        "userName": "test-venkat-1",
                        "sbUid": "abcd_12342222211q2"
                    },
                    {
                        "uid": 20,
                        "userName": "vvaann",
                        "sbUid": "112233"
                    },
                    {
                        "uid": 19,
                        "userName": "venkat-btech",
                        "sbUid": "12f61a0248"
                    },
                    {
                        "uid": 18,
                        "userName": "ntptest104",
                        "sbUid": "8454cb21-3ce9-4e30-85b5-fade097880d8"
                    },
                    {
                        "uid": 1,
                        "userName": "admin",
                        "sbUid": null
                    },
                    {
                        "uid": 14,
                        "userName": "test-venkat",
                        "sbUid": "abcd_123422222"
                    },
                    {
                        "uid": 13,
                        "userName": "PublicUser",
                        "sbUid": null
                    },
                    {
                        "uid": 12,
                        "userName": "Mentor",
                        "sbUid": null
                    },
                    {
                        "uid": 11,
                        "userName": "venkat00342343",
                        "sbUid": "efgh_56785454333"
                    },
                    {
                        "uid": 10,
                        "userName": "venkat00342",
                        "sbUid": "efgh_56785454"
                    }
                ]
            },
            {
                "name": "verified-users",
                "members": [
                    {
                        "uid": 1,
                        "userName": "admin",
                        "sbUid": null
                    }
                ]
            },
            {
                "name": "unverified-users",
                "members": [
                    {
                        "uid": 9,
                        "userName": "venkat002",
                        "sbUid": "efgh_5678"
                    },
                    {
                        "uid": 8,
                        "userName": "venkat001",
                        "sbUid": "abcd_1234"
                    },
                    {
                        "uid": 4,
                        "userName": "testUser",
                        "sbUid": null
                    },
                    {
                        "uid": 26,
                        "userName": "dsbfjdsf",
                        "sbUid": "45454646461112333"
                    },
                    {
                        "uid": 7,
                        "userName": "ven1",
                        "sbUid": null
                    },
                    {
                        "uid": 6,
                        "userName": "venkat-group 0",
                        "sbUid": null
                    },
                    {
                        "uid": 5,
                        "userName": "venkat-test",
                        "sbUid": null
                    },
                    {
                        "uid": 3,
                        "userName": "Vinu",
                        "sbUid": null
                    },
                    {
                        "uid": 25,
                        "userName": "fsbmbgbfsgs",
                        "sbUid": "4545464646"
                    },
                    {
                        "uid": 24,
                        "userName": "vvaanqqeeeqnuuydddy",
                        "sbUid": "1122311135656333w"
                    },
                    {
                        "uid": 23,
                        "userName": "vvaanqqeeeqnuuyy",
                        "sbUid": "112231113565633"
                    },
                    {
                        "uid": 2,
                        "userName": "venkat",
                        "sbUid": null
                    },
                    {
                        "uid": 16,
                        "userName": "test-venkat-2",
                        "sbUid": "abcd_12342222211q233232"
                    },
                    {
                        "uid": 22,
                        "userName": "vvaanqqeeeqn",
                        "sbUid": "11223111333"
                    },
                    {
                        "uid": 21,
                        "userName": "vvaanqqqn",
                        "sbUid": "112231113"
                    },
                    {
                        "uid": 20,
                        "userName": "vvaann",
                        "sbUid": "112233"
                    },
                    {
                        "uid": 19,
                        "userName": "venkat-btech",
                        "sbUid": "12f61a0248"
                    },
                    {
                        "uid": 18,
                        "userName": "ntptest104",
                        "sbUid": "8454cb21-3ce9-4e30-85b5-fade097880d8"
                    },
                    {
                        "uid": 17,
                        "userName": "test-venkat-22",
                        "sbUid": "abcd_12342222211q2332322222"
                    },
                    {
                        "uid": 15,
                        "userName": "test-venkat-1",
                        "sbUid": "abcd_12342222211q2"
                    },
                    {
                        "uid": 14,
                        "userName": "test-venkat",
                        "sbUid": "abcd_123422222"
                    },
                    {
                        "uid": 13,
                        "userName": "PublicUser",
                        "sbUid": null
                    },
                    {
                        "uid": 12,
                        "userName": "Mentor",
                        "sbUid": null
                    },
                    {
                        "uid": 11,
                        "userName": "venkat00342343",
                        "sbUid": "efgh_56785454333"
                    },
                    {
                        "uid": 10,
                        "userName": "venkat00342",
                        "sbUid": "efgh_56785454"
                    }
                ]
            },
            {
                "name": "Course Mentor",
                "members": [
                    {
                        "uid": 9,
                        "userName": "venkat002",
                        "sbUid": "efgh_5678"
                    },
                    {
                        "uid": 8,
                        "userName": "venkat001",
                        "sbUid": "abcd_1234"
                    },
                    {
                        "uid": 12,
                        "userName": "Mentor",
                        "sbUid": null
                    },
                    {
                        "uid": 1,
                        "userName": "admin",
                        "sbUid": null
                    }
                ]
            }
        ]
    }
}

2. Add multiple users into multiple groups

End Point

Code Block
{{host}}/api/forum/v3/group/membership

Request Body

Code Block
{
    "request": {
        "groups": [
            "Course owner" // nodebb group name
        ],
        "members": [
            {
                "sbUid": "8454cb21-3ce9-4e30-85b5-fade097880d8", // sunbird user identifier
                "sbUserName": "ntptest104" // sunbird username
            }
        ]
    }
}

Response

This api will return list of users added into that group along with newly added user.

Code Block
{
    "id": ".api.forum.v3.group.membership",
    "ver": "1.0",
    "ets": 1615211148516,
    "params": {
        "resmsgid": "9f62cf7a-ec3c-4939-a0f7-aa71a0f1b233",
        "msgid": "",
        "status": "Success"
    },
    "responseCode": "OK",
    "result": {
        "groups": [
            {
                "name": "Course owner",
                "members": [
                    {
                        "uid": 2,
                        "userName": "venkat",
                        "sbUid": null
                    },
                    {
                        "uid": 18,
                        "userName": "ntptest104",
                        "sbUid": "8454cb21-3ce9-4e30-85b5-fade097880d8"
                    },
                    {
                        "uid": 17,
                        "userName": "test-venkat-22",
                        "sbUid": "abcd_12342222211q2332322222"
                    },
                    {
                        "uid": 16,
                        "userName": "test-venkat-2",
                        "sbUid": "abcd_12342222211q233232"
                    },
                    {
                        "uid": 15,
                        "userName": "test-venkat-1",
                        "sbUid": "abcd_12342222211q2"
                    },
                    {
                        "uid": 1,
                        "userName": "admin",
                        "sbUid": null
                    }
                ]
            }
        ]
    }
}

3. To check list of privileges added to a particular group with a category.

End Point

Code Block
{{host}}/api/forum/v3/category/:cid/privileges

Request

Code Block
{
    "request": {
        "groups": [
            "Owner Group",
            "registered-users"
        ]
    }
}

Response Body

Code Block
{
    "id": ".api.forum.v3.category.268.privileges",
    "ver": "1.0",
    "ets": 1615211430805,
    "params": {
        "resmsgid": "51c04946-2213-4c6f-b258-1f00425170e0",
        "msgid": "",
        "status": "Success"
    },
    "responseCode": "OK",
    "result": {
        "groups": [
            {
                "name": "Owner Group",
                "nameEscaped": "Owner Group",
                "privileges": {
                    "groups:find": false,
                    "groups:read": false,
                    "groups:topics:read": false,
                    "groups:topics:create": true,
                    "groups:topics:reply": true,
                    "groups:topics:tag": false,
                    "groups:posts:edit": false,
                    "groups:posts:history": false,
                    "groups:posts:delete": false,
                    "groups:posts:upvote": false,
                    "groups:posts:downvote": false,
                    "groups:topics:delete": false,
                    "groups:posts:view_deleted": false,
                    "groups:purge": false,
                    "groups:moderate": true
                },
                "isPrivate": true,
                "isSystem": false
            },
            {
                "name": "registered-users",
                "nameEscaped": "registered-users",
                "privileges": {
                    "groups:find": true,
                    "groups:read": true,
                    "groups:topics:read": true,
                    "groups:topics:create": false,
                    "groups:topics:reply": false,
                    "groups:topics:tag": true,
                    "groups:posts:edit": true,
                    "groups:posts:history": true,
                    "groups:posts:delete": true,
                    "groups:posts:upvote": true,
                    "groups:posts:downvote": true,
                    "groups:topics:delete": true,
                    "groups:posts:view_deleted": false,
                    "groups:purge": false,
                    "groups:moderate": false
                },
                "newCidisPrivate": 5true,
        "cids": [       "isSystem": true
  5         ] }
     }   ]
 ]   }
}