DataFlex / Microsoft Graph / Create retentionLabel
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.
// {
// "displayName": "{{labelDisplayName}}",
// "behaviorDuringRetentionPeriod": "retain",
// "actionAfterRetentionPeriod": "none",
// "retentionTrigger": "dateLabeled",
// "retentionDuration": {
// "@odata.type": "microsoft.graph.security.retentionDurationInDays",
// "days": "2555"
// },
// "descriptionForAdmins": "{{labelDescriptionForAdmins}}",
// "descriptionForUsers": "{{labelDescriptionForUsers}}"
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "displayName" "{{labelDisplayName}}" To iSuccess
Get ComUpdateString Of hoJson "behaviorDuringRetentionPeriod" "retain" To iSuccess
Get ComUpdateString Of hoJson "actionAfterRetentionPeriod" "none" To iSuccess
Get ComUpdateString Of hoJson "retentionTrigger" "dateLabeled" To iSuccess
Get ComUpdateString Of hoJson 'retentionDuration."@odata.type"' "microsoft.graph.security.retentionDurationInDays" To iSuccess
Get ComUpdateString Of hoJson "retentionDuration.days" "2555" To iSuccess
Get ComUpdateString Of hoJson "descriptionForAdmins" "{{labelDescriptionForAdmins}}" To iSuccess
Get ComUpdateString Of hoJson "descriptionForUsers" "{{labelDescriptionForUsers}}" 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://graph.microsoft.com/beta/security/labels/retentionLabels" "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 '{
"displayName": "{{labelDisplayName}}",
"behaviorDuringRetentionPeriod": "retain",
"actionAfterRetentionPeriod": "none",
"retentionTrigger": "dateLabeled",
"retentionDuration": {
"@odata.type": "microsoft.graph.security.retentionDurationInDays",
"days": "2555"
},
"descriptionForAdmins": "{{labelDescriptionForAdmins}}",
"descriptionForUsers": "{{labelDescriptionForUsers}}"
}'
https://graph.microsoft.com/beta/security/labels/retentionLabels
Postman Collection Item JSON
{
"name": "Create retentionLabel",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var json = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"retentionLabelId\", json.id);"
]
}
}
],
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"displayName\": \"{{labelDisplayName}}\",\n \"behaviorDuringRetentionPeriod\": \"retain\",\n \"actionAfterRetentionPeriod\": \"none\",\n \"retentionTrigger\": \"dateLabeled\",\n \"retentionDuration\": {\n \"@odata.type\": \"microsoft.graph.security.retentionDurationInDays\",\n \"days\": \"2555\"\n },\n \"descriptionForAdmins\": \"{{labelDescriptionForAdmins}}\",\n \"descriptionForUsers\": \"{{labelDescriptionForUsers}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://graph.microsoft.com/beta/security/labels/retentionLabels",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"beta",
"security",
"labels",
"retentionLabels"
]
}
},
"response": [
]
}