CREATE Group
POST {{baseUrl}}/api/v1/groups
Use the POST {{baseUrl}}/api/v1/groups request to create a PingCentral group.
Body
raw ( application/json )
{
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
}
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{baseUrl}}/api/v1/groups' \
--header 'Cookie: <string>' \
--header 'X-XSRF-Header: PASS' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==' \
--data '{
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
}'
var options = new RestClientOptions("{{baseUrl}}/api/v1/groups")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Cookie", "<string>");
request.AddHeader("X-XSRF-Header", "PASS");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==");
var body = @"{" + "\n" +
@" ""created"": ""2020-12-03T12:52:25.973290Z""," + "\n" +
@" ""description"": ""Description of the group.""," + "\n" +
@" ""displayName"": ""All Employees""," + "\n" +
@" ""id"": ""cd00f834-0c26-45ec-9410-cc38156cb4d4""," + "\n" +
@" ""members"": [" + "\n" +
@" {" + "\n" +
@" ""firstName"": ""Default""," + "\n" +
@" ""id"": ""cd00f834-0c26-45ec-9410-cc38156cb4d4""," + "\n" +
@" ""lastName"": ""User""," + "\n" +
@" ""source"": ""PASS-ISS""," + "\n" +
@" ""username"": ""administrator""" + "\n" +
@" }" + "\n" +
@" ]," + "\n" +
@" ""modified"": ""2020-12-03T12:52:25.973290Z""," + "\n" +
@" ""name"": ""Company-Employees""," + "\n" +
@" ""source"": ""PASS-ISS""" + "\n" +
@"}" + "\n" +
@"";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/api/v1/groups"
method := "POST"
payload := strings.NewReader(`{
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Cookie", "<string>")
req.Header.Add("X-XSRF-Header", "PASS")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
POST /api/v1/groups HTTP/1.1
Host: {{baseUrl}}
Cookie: <string>
X-XSRF-Header: PASS
Content-Type: application/json
Authorization: Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==
{
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"created\": \"2020-12-03T12:52:25.973290Z\",\n \"description\": \"Description of the group.\",\n \"displayName\": \"All Employees\",\n \"id\": \"cd00f834-0c26-45ec-9410-cc38156cb4d4\",\n \"members\": [\n {\n \"firstName\": \"Default\",\n \"id\": \"cd00f834-0c26-45ec-9410-cc38156cb4d4\",\n \"lastName\": \"User\",\n \"source\": \"PASS-ISS\",\n \"username\": \"administrator\"\n }\n ],\n \"modified\": \"2020-12-03T12:52:25.973290Z\",\n \"name\": \"Company-Employees\",\n \"source\": \"PASS-ISS\"\n}\n");
Request request = new Request.Builder()
.url("{{baseUrl}}/api/v1/groups")
.method("POST", body)
.addHeader("Cookie", "<string>")
.addHeader("X-XSRF-Header", "PASS")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{baseUrl}}/api/v1/groups",
"method": "POST",
"timeout": 0,
"headers": {
"Cookie": "<string>",
"X-XSRF-Header": "PASS",
"Content-Type": "application/json",
"Authorization": "Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ=="
},
"data": JSON.stringify({
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{baseUrl}}/api/v1/groups',
'headers': {
'Cookie': '<string>',
'X-XSRF-Header': 'PASS',
'Content-Type': 'application/json',
'Authorization': 'Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ=='
},
body: JSON.stringify({
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "{{baseUrl}}/api/v1/groups"
payload = json.dumps({
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
})
headers = {
'Cookie': '<string>',
'X-XSRF-Header': 'PASS',
'Content-Type': 'application/json',
'Authorization': 'Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ=='
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{baseUrl}}/api/v1/groups');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Cookie' => '<string>',
'X-XSRF-Header' => 'PASS',
'Content-Type' => 'application/json',
'Authorization' => 'Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ=='
));
$request->setBody('{\n "created": "2020-12-03T12:52:25.973290Z",\n "description": "Description of the group.",\n "displayName": "All Employees",\n "id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",\n "members": [\n {\n "firstName": "Default",\n "id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",\n "lastName": "User",\n "source": "PASS-ISS",\n "username": "administrator"\n }\n ],\n "modified": "2020-12-03T12:52:25.973290Z",\n "name": "Company-Employees",\n "source": "PASS-ISS"\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
require "uri"
require "json"
require "net/http"
url = URI("{{baseUrl}}/api/v1/groups")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Cookie"] = "<string>"
request["X-XSRF-Header"] = "PASS"
request["Content-Type"] = "application/json"
request["Authorization"] = "Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ=="
request.body = JSON.dump({
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
})
response = http.request(request)
puts response.read_body
let parameters = "{\n \"created\": \"2020-12-03T12:52:25.973290Z\",\n \"description\": \"Description of the group.\",\n \"displayName\": \"All Employees\",\n \"id\": \"cd00f834-0c26-45ec-9410-cc38156cb4d4\",\n \"members\": [\n {\n \"firstName\": \"Default\",\n \"id\": \"cd00f834-0c26-45ec-9410-cc38156cb4d4\",\n \"lastName\": \"User\",\n \"source\": \"PASS-ISS\",\n \"username\": \"administrator\"\n }\n ],\n \"modified\": \"2020-12-03T12:52:25.973290Z\",\n \"name\": \"Company-Employees\",\n \"source\": \"PASS-ISS\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{baseUrl}}/api/v1/groups")!,timeoutInterval: Double.infinity)
request.addValue("<string>", forHTTPHeaderField: "Cookie")
request.addValue("PASS", forHTTPHeaderField: "X-XSRF-Header")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==", forHTTPHeaderField: "Authorization")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()
Example Response
201 Created
{
"created": "2020-12-03T12:52:25.973290Z",
"description": "Description of the group.",
"displayName": "All Employees",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"members": [
{
"firstName": "Default",
"id": "cd00f834-0c26-45ec-9410-cc38156cb4d4",
"lastName": "User",
"source": "PASS-ISS",
"username": "administrator"
}
],
"modified": "2020-12-03T12:52:25.973290Z",
"name": "Company-Employees",
"source": "PASS-ISS"
}