Step 2: Create a population to synchronize with Workday
POST {{apiPath}}/environments/{{envID}}/populations
In Step 7: Create a Workday propagation rule, you must provide an expression that selects a population of users to synchronize from Workday. One method (the method used in this use case) selects all users that belong to a particular PingOne population, identified by its population UUID. While an existing PingOne population can be used, this use case creates the population for Step 7 in this step. Creating a population requires a password policy to apply to users in its population. While an existing PingOne password policy can be used, this use case creates the password policy for this step in Step 1: Create a password policy for the Workday population.
Use POST {{apiPath}}/environments/{{envID}}/populations/ to create a Workday population in the specified environment.
In the request body, the population name is a required property. The description property is optional.
Populations, by default, use the password policy of their environment. However, you can optionally assign a password policy specific to this population with the passwordPolicy.id property in the request body. To unassign the passwordPolicy.id property, omit passwordPolicy.id from the request body and the population again uses the default password policy.
Request Model
| Property | Type | Required? |
|---|---|---|
|
String |
Optional |
|
String |
Required |
|
String |
Optional |
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{apiPath}}/environments/{{envID}}/populations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
"name": "Workday {{$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/populations")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer {{accessToken}}");
var body = @"{" + "\n" +
@" ""name"": ""Workday {{$timestamp}}""," + "\n" +
@" ""description"": ""Population of users in Workday""," + "\n" +
@" ""passwordPolicy"": {" + "\n" +
@" ""id"": ""{{wdPasswordPolicyID}}""" + "\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 := "{{apiPath}}/environments/{{envID}}/populations"
method := "POST"
payload := strings.NewReader(`{
"name": "Workday {{$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer {{accessToken}}")
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 /environments/{{envID}}/populations HTTP/1.1
Host: {{apiPath}}
Content-Type: application/json
Authorization: Bearer {{accessToken}}
{
"name": "Workday {{$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"name\": \"Workday {{$timestamp}}\",\n \"description\": \"Population of users in Workday\",\n \"passwordPolicy\": {\n \"id\": \"{{wdPasswordPolicyID}}\"\n }\n}");
Request request = new Request.Builder()
.url("{{apiPath}}/environments/{{envID}}/populations")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {{accessToken}}")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{apiPath}}/environments/{{envID}}/populations",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer {{accessToken}}"
},
"data": JSON.stringify({
"name": "Workday {{$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{apiPath}}/environments/{{envID}}/populations',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{accessToken}}'
},
body: JSON.stringify({
"name": "Workday {{$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "{{apiPath}}/environments/{{envID}}/populations"
payload = json.dumps({
"name": "Workday {{$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{accessToken}}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/environments/{{envID}}/populations');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {{accessToken}}'
));
$request->setBody('{\n "name": "Workday {{$timestamp}}",\n "description": "Population of users in Workday",\n "passwordPolicy": {\n "id": "{{wdPasswordPolicyID}}"\n }\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("{{apiPath}}/environments/{{envID}}/populations")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer {{accessToken}}"
request.body = JSON.dump({
"name": "Workday {{\$timestamp}}",
"description": "Population of users in Workday",
"passwordPolicy": {
"id": "{{wdPasswordPolicyID}}"
}
})
response = http.request(request)
puts response.read_body
let parameters = "{\n \"name\": \"Workday {{$timestamp}}\",\n \"description\": \"Population of users in Workday\",\n \"passwordPolicy\": {\n \"id\": \"{{wdPasswordPolicyID}}\"\n }\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envID}}/populations")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{accessToken}}", 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
{
"_links": {
"self": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/populations/cd053929-8971-42e3-a5e2-9b3dde933ffd"
},
"environment": {
"href": "https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
}
},
"id": "cd053929-8971-42e3-a5e2-9b3dde933ffd",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"name": "Workday",
"description": "Population of users in Workday",
"userCount": 0,
"createdAt": "2022-10-11T14:39:11.785Z",
"updatedAt": "2022-10-11T14:39:11.785Z",
"passwordPolicy": {
"id": "deff20db-310e-4de3-a519-372f89c371fb"
},
"default": false
}