Thursday, 8 November 2018

Python application - Dynamics 365


you can access the Microsoft Dynamics 365 using  the following approach.


The following method works for  dynamics 365  V9.0

NOTE: You have to register the CRM app in Azure AAD to get ClientID & secret, later those can be used to get access tokens & interact with CRM web api from outside applications like java/php/.net web applications.


- Installing ` pip install dynamics365crm-python `
- Usage If you will not use the oauth authentication and you already have an access token, call the library like this: - resource = the url of the CRM, example: https://example.crm2.dynamics.com/ ` from dynamics365crm.client import Client client = Client('RESOURCE', 'ACCESS_TOKEN') `
-If you will use the oauth authentication call the library like this: ` from dynamics365crm.client import Client client = Client('RESOURCE',CLIENT_ID', 'CLIENT_SECRET') `
- Get authorization url ` url = client.url_petition("REDIRECT_URL") `
- Exchange the code for an access token ` token =client.exchange_code('REDIRECT_URL', 'CODE') `
- Refresh token ` token = client.refresh_token('REFRESH TOKEN', 'REDIRECT_URL') `
- Set token ` token = client.set_token('TOKEN') ` 

CONTACT ENTITY CRUD 
- Get Contacts can receive orderby, filter, select, top, expand ` list_contacts = client.get_contacts() `
- Create Contact ` create_contact =client.create_contact(firstname="FIRSTNAME", lastname="LASTNAME",middlename="MIDDLENAME", emailaddress1="EMAILADDRESS") `
- Delete Contact ` delete_contact = client.delete_contact('ID') `
- Update Contact ` update_contact = client.update_contact('ID',firstname="FIRSTNAME", lastname="LASTNAME", middlename="MIDDLENAME",emailaddress1="EMAILADDRESS") `

ACCOUNT ENTITY CRUD
- Get Accounts can receive orderby, filter, select, top, expand ` get_accounts = client.get_accounts() `
- Create Account ` create_account = client.create_account(name="NAME",websiteurl="WWW.WEBSITE.COM") `
- Delete Account ` create_account = client.delete_account('ID') `
- Update Account ` update_account = client.update_account(id="ID",name="NAME") `

OPPORTUNITY ENTITY CRUD
- Get Opportunities can receive orderby, filter, select, top, expand ` list_opportunities = client.get_opportunities() `
- Create Opportunities ` create_opportunities =client.create_opportunity(name="OPPORTUNITY NAME") `
- Delete Opportunities ` delete_opportunities =client.delete_opportunity(id="OPPORTUNITY ID") `
- Update Opportunities ` update_opportunities =client.update_opportunity(id="OPPORTUNITY ID", name="OPPORTUNITY NAME",description="SOME DESCRIPTION") `

LEAD ENTITY CRUD
- Get Leads can receive orderby, filter, select, top, expand ` list_leads = client.get_leads() `
- Create Lead ` create_leads = client.create_lead(fullname="LEAD NAME",subject="LEAD SUBJECT", mobilephone="123456",websiteurl="WWW.WEBSITE.COM", middlename="MIDDLE LEAD NAME") `
 - Delete Lead ` delete_leads = client.delete_lead("ID") `
- Update Lead ` update_leads = client.update_lead(fullname="LEAD NAME",subject="LEAD SUBJECT", mobilephone="123456",websiteurl="WWW.WEBSITE.COM", middlename="MIDDLE LEAD NAME") `

CAMPAIGN ENTITY CRUD
- Get Campaigns can receive orderby, filter, select, top, expand ` list_campaigns = client.get_campaigns() `
- Create Campaign ` create_campaign =client.create_campaign(name="CAMPAIGN NAME", description="SOMEDESCRIPTION") `
- Delete Campaign ` delete_campaign = client.delete_campaign(id="ID") `
- Update Campaign ` update_campaign = client.update_campaign(id="ID",name="CAMPAIGN NAME", description="SOME DESCRIPTION") `
-Requirements - requests
-Tests ` dynamics365crm/test.py `

5 comments:

Power Apps Drag & Drop Kanban code sample

  Introduction: The Kanban Board App Developers at a software company use the Kanban board to show their progress on development tasks and b...