-
Obtain authentication token
XHOST=rocketchat.dev.company.com:3000 curl -H "Content-type:application/json" \ http://${XHOST}/api/v1/login \ -d '{ "username": "test", "password": "test" }'
-
Store tokens in variable
XUID=mvkPzDTnebrnCuwPa XAT=ZCev4fFxUbJTEYknDZCyrIvh5htuBQEQH9JAxyjBwy7
-
Call
channel.create
to create (public) channelcurl -H "X-Auth-Token: ${XAT}" \ -H "X-User-Id: ${XUID}" \ -H "Content-type: application/json" \ http://${XHOST}/api/v1/channels.create \ -d '{ "name": "Test_1" }'
{ "channel": { "_id": "yAHBiDsRchnhj4NXf", "name": "Test_1", "fname": "Test_1", "t": "c", "msgs": 0, "u": { "_id": "mvkPzDTnebrnCuwPa", "username": "test" }, "customFields": {}, "ts": "2018-04-17T07:46:25.025Z", "ro": false, "sysMes": true, "_updatedAt": "2018-04-17T07:46:25.025Z" }, "success": true, "developerWarning": "[WARNING]: The \"usernames\" field has been removed for performance reasons. Please use the \"*.members\" endpoint to get a list of members/users in a room." }
-
Change type to
p
(rivate group) usingchannels.setType
curl -H "X-Auth-Token: ${XAT}" \ -H "X-User-Id: ${XUID}" \ -H "Content-type: application/json" \ http://${XHOST}/api/v1/channels.setType \ -d '{ "roomId": "yAHBiDsRchnhj4NXf", "type": "p" }'
{ "channel": { "_id": "yAHBiDsRchnhj4NXf", "name": "Test_1", "fname": "Test_1", "t": "p", "msgs": 1, "u": { "_id": "mvkPzDTnebrnCuwPa", "username": "test" }, "customFields": {}, "ts": "2018-04-17T07:46:25.025Z", "ro": false, "sysMes": true, "_updatedAt": "2018-04-17T07:46:55.296Z" }, "success": true, "developerWarning": "[WARNING]: The \"usernames\" field has been removed for performance reasons. Please use the \"*.members\" endpoint to get a list of members/users in a room." }
-
Change type back to
c
(hannel) usinggroups.setType
curl -H "X-Auth-Token: ${XAT}" \ -H "X-User-Id: ${XUID}" \ -H "Content-type: application/json" \ http://${XHOST}/api/v1/groups.setType \ -d '{ "roomId": "yAHBiDsRchnhj4NXf", "type": "c" }'
{ "group": { "_id": "yAHBiDsRchnhj4NXf", "name": "Test_1", "fname": "Test_1", "t": "c", "msgs": 2, "u": { "_id": "mvkPzDTnebrnCuwPa", "username": "test" }, "customFields": {}, "ts": "2018-04-17T07:46:25.025Z", "ro": false, "sysMes": true, "_updatedAt": "2018-04-17T07:48:02.123Z" }, "success": true, "developerWarning": "[WARNING]: The \"usernames\" field has been removed for performance reasons. Please use the \"*.members\" endpoint to get a list of members/users in a room." }
Last active
January 16, 2019 14:31
-
-
Save frdmn/fec5e5865cb7e794809143db61991c64 to your computer and use it in GitHub Desktop.
Rocket.Chat REST API setType channel/group
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment