unicodeC / MongoDB Atlas / Add Users to Team
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
const wchar_t *strRequestBody;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_putDigestAuth(http,TRUE);
CkHttpW_putLogin(http,L"username");
CkHttpW_putPassword(http,L"password");
strRequestBody = L"[{ \"id\" : \"{{USER-ID}}\" }]";
resp = CkHttpW_PText(http,L"POST",L"https://domain.com/api/atlas/{{version}}/orgs/{{ORG-ID}}/teams/{{TEAM-ID}}/users",strRequestBody,L"utf-8",L"application/text",FALSE,FALSE);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
}
Curl Command
curl -X POST
--digest -u 'username:password'
-d '[{ "id" : "{{USER-ID}}" }]'
https://domain.com/api/atlas/{{version}}/orgs/{{ORG-ID}}/teams/{{TEAM-ID}}/users
Postman Collection Item JSON
{
"name": "Add Users to Team",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "[{ \"id\" : \"{{USER-ID}}\" }]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{base_url}}/api/atlas/{{version}}/orgs/{{ORG-ID}}/teams/{{TEAM-ID}}/users",
"host": [
"{{base_url}}"
],
"path": [
"api",
"atlas",
"{{version}}",
"orgs",
"{{ORG-ID}}",
"teams",
"{{TEAM-ID}}",
"users"
]
},
"description": "https://docs.atlas.mongodb.com/reference/api/teams-add-user/"
},
"response": [
]
}