I have a requirement to fetch and show all the available Relationships of an Entity on HTML page, separately. Eg: If I chose, Account, in the html page, I should be able to see 1:N, N:1 and N:N relationships of Account Entity.
I have tried below, queries and I feel, these are not helping me correctly, Please suggest me a workaround for this to achieve.
https://<CRMORGNAME>/api/data/v8.2/RelationshipDefinitions/Microsoft.Dynamics.CRM.ManyToOneRelationshipMetadata?$select=Entity1LogicalName,SchemaName&$filter=Entity1LogicalName eq 'account'
https://<CRMORGNAME>/api/data/v8.2/RelationshipDefinitions?$select=RelationshipType,SchemaName
You can do it the following way:
One to many:
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/OneToManyRelationships?$select=SchemaName,RelationshipType
Many to one:
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/ManyToOneRelationships?$select=SchemaName,RelationshipType
Many to many:
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/ManyToManyRelationships?$select=SchemaName,RelationshipType
Of course you should first get the proper EntityDefinition id (the '70816501-edb9-4740-a16c-6a5efbc05d84' is for account in this case)
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions?$select=SchemaName,LogicalName,MetadataId&$filter=LogicalName eq 'account'