Web API Complex and Enumeration types

Within the CSDL $metadata document, you will find ComplexType and EnumType elements.

Complex types

Complex types are keyless named structured types consisting of a set of properties. Complex types are commonly used as property values in table definitions, or as parameters or return values for operations.

For example the WhoAmI Function returns this WhoAmIResponse ComplexType:

<ComplexType Name="WhoAmIResponse">  
  <Property Name="BusinessUnitId" Type="Edm.Guid" Nullable="false" />  
  <Property Name="UserId" Type="Edm.Guid" Nullable="false" />  
  <Property Name="OrganizationId" Type="Edm.Guid" Nullable="false" />  
</ComplexType>

Enumeration types

Enumeration types are named primitive types whose values are named constants with underlying integer values.

For example, the following is the definition of the AccessRights EnumType

<EnumType Name="AccessRights">  
  <Member Name="None" Value="0" />  
  <Member Name="ReadAccess" Value="1" />  
  <Member Name="WriteAccess" Value="2" />  
  <Member Name="AppendAccess" Value="4" />  
  <Member Name="AppendToAccess" Value="16" />  
  <Member Name="CreateAccess" Value="32" />  
  <Member Name="DeleteAccess" Value="65536" />  
  <Member Name="ShareAccess" Value="262144" />  
  <Member Name="AssignAccess" Value="524288" />  
</EnumType>

The AccessRights enum type is used for the AccessMask property of the PrincipalAccess ComplexType, which is used to set the PrincipalAccess parameter for the ModifyAccess Action. This is the action used to change the access when sharing a record.

The example below grants ReadAccess, WriteAccess, DeleteAccess, AppendAccess, and AssignAccess access rights to the account record specified by the Target parameter to the systemuser designated by the Principal property of the PrincipalAccess complex type.

Request:

POST [Organization URI]/api/data/v9.0/ModifyAccess
OData-Version: 4.0
OData-MaxVersion: 4.0
Content-Type: application/json; charset=UTF-8
Accept: application/json

{
    "Target": {
        "accountid": "cbcf8bbc-aa41-ec11-8c62-000d3a53893c",
        "@odata.type": "Microsoft.Dynamics.CRM.account"
    },
    "PrincipalAccess": {
        "Principal": {
            "systemuserid": "8061643d-ebf7-e811-a974-000d3a1e1c9a",
            "@odata.type": "Microsoft.Dynamics.CRM.systemuser"
        },
        "AccessMask": "ReadAccess,WriteAccess,DeleteAccess,AppendAccess,AssignAccess"
    }
}

Response:

HTTP/1.1 204 No Content

Next steps

Perform operations using the Web API.

See also

Web API types and operations
Web API Service Documents
Web API EntityTypes
Web API Properties
Web API Navigation Properties
Web API Actions
Web API Functions
Use the Dataverse Web API
OData Version 4.0. Complex Type
OData Version 4.0 Enumeration Type