Dynamics Web API Client
pip install dynamics-client
Documentation: https://mrthearman.github.io/dynamics-client/
Source Code: https://github.com/MrThearMan/dynamics-client/
Contributing: https://github.com/MrThearMan/dynamics-client/blob/main/CONTRIBUTING.md
Client for making Web API request from a Microsoft Dynamics 365 Database.
You should also read the Dynamics Web API Reference Docs:
Basic usage:
from dynamics import DynamicsClient, ftr
client = DynamicsClient(...)
client.table = "accounts"
client.select = ["accountid", "name"]
client.filter = [
ftr.on_or_after("createdon", "2020-01-01T00:00:00Z"),
ftr.ge("numberofemployees", 200),
]
client.expand = {
"contact_customer_accounts": {
"select": ["firstname", "lastname", "mobilephone"],
"filter": {
ftr.contains("emailaddress1", "gmail.com"),
ftr.contains("emailaddress2", "gmail.com"),
}
},
"primarycontactid": {
"select": ["emailaddress1"],
},
}
result = client.get()
print(result.data)
client.reset_query()
client.table = "contacts"
client.select = ["firstname", "lastname", "emailaddress1"]
accountid = ...
data = {
"firstname": ...,
"lastname": ...,
"emailaddress1": ...,
"parentcustomerid_account@odata.bind": f"/accounts({accountid})"
}
result = client.post(data=data)
print(result.data)
client.reset_query()
client.table = "contacts"
client.row_id = result["contactid"]
data = {
"firstname": ...,
"lastname": ...,
}
result = client.patch(data=data)
print(result.data)
client.reset_query()
client.table = "contacts"
client.row_id = result["contactid"]
client.delete()