Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "userName": "{{managedUsername}}",
// "sn": "{{$randomLastName}}",
// "givenName": "{{$randomFirstName}}",
// "mail": "{{managedUsername}}@postman.example.com",
// "telephoneNumber": "{{$randomPhoneNumber}}",
// "password": "{{$randomPassword}}"
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "userName" "{{managedUsername}}" To iSuccess
Get ComUpdateString Of hoJson "sn" "{{$randomLastName}}" To iSuccess
Get ComUpdateString Of hoJson "givenName" "{{$randomFirstName}}" To iSuccess
Get ComUpdateString Of hoJson "mail" "{{managedUsername}}@postman.example.com" To iSuccess
Get ComUpdateString Of hoJson "telephoneNumber" "{{$randomPhoneNumber}}" To iSuccess
Get ComUpdateString Of hoJson "password" "{{$randomPassword}}" To iSuccess
// Adds the "Authorization: Bearer <access_token>" header.
Set ComAuthToken Of hoHttp To "<access_token>"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user?_action=create" "application/json" vJson To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
Send Destroy of hoResp
End_Procedure
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"userName": "{{managedUsername}}",
"sn": "{{$randomLastName}}",
"givenName": "{{$randomFirstName}}",
"mail": "{{managedUsername}}@postman.example.com",
"telephoneNumber": "{{$randomPhoneNumber}}",
"password": "{{$randomPassword}}"
}'
https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user?_action=create
Postman Collection Item JSON
{
"name": "Step 1: Create a Managed Identity",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"pm.globals.set(\"managedUsername\", pm.globals.replaceIn('{{$randomUserName}}'))"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"const jsonData = JSON.parse(responseBody);",
"if(jsonData._id && jsonData._id != \"\"){",
" pm.globals.set(\"managedUserId\", jsonData._id);",
"}",
"if(jsonData.userName && jsonData.userName != \"\"){",
" pm.globals.set(\"managedUsername\", jsonData.userName);",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"userName\": \"{{managedUsername}}\",\n \"sn\": \"{{$randomLastName}}\",\n \"givenName\": \"{{$randomFirstName}}\",\n \"mail\": \"{{managedUsername}}@postman.example.com\",\n \"telephoneNumber\": \"{{$randomPhoneNumber}}\",\n \"password\": \"{{$randomPassword}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{platformUrl}}/openidm/managed/alpha_user?_action=create",
"host": [
"{{platformUrl}}"
],
"path": [
"openidm",
"managed",
"alpha_user"
],
"query": [
{
"key": "_action",
"value": "create"
}
]
},
"description": "Create a new managed identity."
},
"response": [
{
"name": "Success",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "(Required) ",
"key": "Accept-API-Version",
"value": "<string>"
}
],
"url": {
"raw": "{{baseUrl}}/openidm/managed/user#1.0_query_filter?_fields=&_prettyPrint=true&_queryFilter=<string>&_pageSize=<integer>&_totalPagedResultsPolicy=<string>&_sortKeys=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"openidm",
"managed",
"user"
],
"hash": "1.0_query_filter?_fields=&_prettyPrint=true&_queryFilter=<string>&_pageSize=<integer>&_totalPagedResultsPolicy=<string>&_sortKeys=<string>"
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "*/*"
}
],
"cookie": [
],
"body": ""
}
]
}