This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Create Entities
Overview
The following operation allows you to work with create entities.
Operation | Description |
---|---|
Create an entity using Web API. |
For a sample proxy service that illustrates how to work with create entities, see Sample configuration.
Operation details
Following is more information about each of the operations.
Create an Entity
To create an entity using the Web API, use msdynamics365.createEntity
.
<msdynamics365.createEntity> <entityType>{$ctx:entityType}</entityType> <bodyContent>{$ctx:bodyContent}</bodyContent> <queryParam>{$ctx:queryParam}</queryParam> </msdynamics365.createEntity>
Properties
- <entityType>: Mandatory. The type of an entity (i.e., accounts, opportunities, contacts etc).
- <bodyContent>: Mandatory. The body content to create an entity in a different way.
- <queryParam>: Mandatory. Based on query parameters, the requested data will return in the response.
Sample request
Following is a sample REST/JSON request that can be handled by the createEntity
operation in a different way.
{ "apiUrl":"https://wso2.crm5.dynamics.com", "accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3", "refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt", "clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og", "clientId":"c12ec5be-8356-ed0915a", "resource":"https://wso21234.crm5.dynamics.com/", "registryPath":"", "intervalTime":"", "entityType":"accounts", "bodyContent": {"name":"my account"} }
You can create entities related to each other by defining them as navigation property values. This is known as deep insert.
{ "apiUrl":"https://wso2.crm5.dynamics.com", "accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3", "refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt",, "clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og", "clientId":"c12ec5be-8356-ed0915a", "resource":"https://wso21234.crm5.dynamics.com/", "registryPath":"", "intervalTime":"", "entityType":"accounts", "bodyContent": {"name": "Sample Account","primarycontactid":{"firstname": "John"},"opportunity_customer_accounts":[{"name": "Opportunity associated to Sample Account","Opportunity_Tasks":[{ "subject": "Task associated to opportunity" }]}]} }
To associate new entities to existing entities when they are created, you must set the value of single-valued navigation properties using the@odata.bind annotation.
{ "apiUrl":"https://wso2.crm5.dynamics.com", "accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3", "refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt",, "clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og", "clientId":"c12ec5be-8356-ed0915a", "resource":"https://wso21234.crm5.dynamics.com/", "registryPath":"", "intervalTime":"", "entityType":"accounts", "bodyContent": {"name": "Sample Account","primarycontactid@odata.bind":"/contacts(00000000-0000-0000-0000-000000000001)"} }
When the entity is created, the requested data is returned in the response.
{ "apiUrl":"https://wso2.crm5.dynamics.com", "accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3", "refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt", "clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og", "clientId":"c12ec5be-8356-ed0915a", "resource":"https://wso21234.crm5.dynamics.com/", "registryPath":"", "intervalTime":"", "entityType":"accounts", "bodyContent": {"name": "Sample Account","creditonhold": false,"address1_latitude": 47.639583,"description": "test","revenue": 5000000,"accountcategorycode": 1}, "queryParam":"name,creditonhold,address1_latitude,description,revenue,accountcategorycode,createdon" }
For documentation on creating an entity using the Web API, see https://msdn.microsoft.com/en-us/library/gg328090.aspx.
Sample configuration
Following is a sample proxy service that illustrates how to connect to Microsoft Dynamics 365 with the init
operation and use the createEntity
operation. You can find the sample request for this proxy above.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="msdynamics_createEntity" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property expression="json-eval($.apiUrl)" name="apiUrl"/> <property expression="json-eval($.accessToken)" name="accessToken"/> <property expression="json-eval($.entityType)" name="entityType"/> <property expression="json-eval($.bodyContent)" name="bodyContent"/> <property expression="json-eval($.apiVersion)" name="apiVersion"/> <property expression="json-eval($.refreshToken)" name="refreshToken"/> <property expression="json-eval($.clientSecret)" name="clientSecret"/> <property expression="json-eval($.clientId)" name="clientId"/> <property expression="json-eval($.resource)" name="resource"/> <property expression="json-eval($.registryPath)" name="registryPath"/> <property expression="json-eval($.intervalTime)" name="intervalTime"/> <property expression="json-eval($.queryParam)" name="queryParam"/> <msdynamics365.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <accessToken>{$ctx:accessToken}</accessToken> <apiVersion>{$ctx:apiVersion}</apiVersion> <refreshToken>{$ctx:refreshToken}</refreshToken> <clientSecret>{$ctx:clientSecret}</clientSecret> <clientId>{$ctx:clientId}</clientId> <resource>{$ctx:resource}</resource> <registryPath>{$ctx:registryPath}</registryPath> <intervalTime>{$ctx:intervalTime}</intervalTime> </msdynamics365.init> <msdynamics365.createEntity> <entityType>{$ctx:entityType}</entityType> <bodyContent>{$ctx:bodyContent}</bodyContent> <queryParam>{$ctx:queryParam}</queryParam> </msdynamics365.createEntity> <respond/> </inSequence> <outSequence> <send/> </outSequence> </target> <description/> </proxy>