I am trying to create a Schema Extension in Azure Active Directory. But I get this error message:
GraphError { headers: Some(GraphHeaders { url: "https://graph.microsoft.com/v1.0/schemaExtensions", status: 400, header_map: {"cache-control": "no-cache", "transfer-encoding": "chunked", "content-type": "application/json", "strict-transport-security": "max-age=31536000", "request-id": "8b0e00a9-3f69-404d-b78d-30af76bf45d8", "client-request-id": "8b0e00a9-3f69-404d-b78d-30af76bf45d8", "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"West US\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"005\",\"RoleInstance\":\"SJ1PEPF00000BAD\"}}", "x-ms-resource-unit": "1", "date": "Mon, 29 Aug 2022 21:35:23 GMT"} }), code: 400, error_message: ErrorMessage { error: Some(ErrorStatus { code: Some("Request_BadRequest"), message: Some("Object of class ComplexExtensionDefinition is not valid for Megatenant with ContextId: 0dd6c721-d5fc-4450-b331-**. Update to segmentation metadata failed."), inner_error: Some(InnerError { code: None, request_id: Some("8b0e00a9-3f69-404d-b78d-30af76bf45d8"), date: Some("2022-08-29T21:35:24") }) }) } }
Seems like Azure AD tenant doesn't support schema extensions?
Here is the code:
use graph_rs_sdk::oauth::OAuth;
use reqwest::StatusCode;
use graph_rs_sdk::prelude::*;
use graph_rs_sdk::error::GraphFailure;
pub async fn account_ext(client: OAuth) -> Result<StatusCode, GraphFailure> {
let graph_client = Graph::new_async(client.get_access_token().unwrap().bearer_token());
let properties = serde_json::json!({
"id": "tenantaccountExt",
"description": "Tenant account extension properties",
"targetTypes": [
"Group"
],
"status": "InDevelopment",
"owner": "90fd44ac-18d2-4920-909b-***********",
"properties": [
{
"name": "region",
"type": "String"
},
{
"name": "contact",
"type": "String"
},
]
});
match graph_client.v1()
.schema_extensions()
.create_schema_extension(&properties)
.send()
.await {
Ok(response) => Ok(response.status()),
Err(GraphFailure::GraphError(err)) => {
println!("{:?}", err);
Ok(err.code)
},
Err(err) => Err(err)
}
}