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
# Init the client:
client = DynamicsClient(...)
### Example GET request:
client.table = "accounts"
# Get only these columns for the account.
client.select = ["accountid", "name"]
# Filter to only the accounts that have been created on or after the
# given ISO date string, AND that have 200 or more employees.
client.filter = [
ftr.on_or_after("createdon", "2020-01-01T00:00:00Z"),
ftr.ge("numberofemployees", 200),
]
# Expand to the contacts (collection-values navigation property)
# on the account that have 'gmail.com' in their email address 1 OR 2.
# Get only the 'firstname', 'lastname' and 'mobilephone' columns for these contacts.
# Also expand the primary contact (single-valued navigation property).
# Get only the 'emailaddress1' column for the primary contact.
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)
# [
# {
# "accountid": ...,
# "name": ...,
# "contact_customer_accounts": [
# {
# "contactid": ..., # id field is always given
# "firstname": ...,
# "lastname": ...,
# "mobilephone": ...
# },
# ...
# ],
# "primarycontactid": {
# "contactid": ...,
# "emailaddress1": ...
# }
# },
# ...
# ]
### Example POST request
# IMPORTANT!!!
client.reset_query()
client.table = "contacts"
# Get only these columns from the created contact
client.select = ["firstname", "lastname", "emailaddress1"]
# The data to create the contact with. '@odata.bind' is used to link
# the contact to the given navigation property.
accountid = ...
data = {
"firstname": ...,
"lastname": ...,
"emailaddress1": ...,
"parentcustomerid_account@odata.bind": f"/accounts({accountid})"
}
result = client.post(data=data)
print(result.data)
# {
# "contactid": ...,
# "firstname": ...,
# "lastname": ...,
# "emailaddress1": ...
# }
### Example PATCH request
client.reset_query()
client.table = "contacts"
client.row_id = result["contactid"]
data = {
"firstname": ...,
"lastname": ...,
}
result = client.patch(data=data)
print(result.data)
# Return all rows on the updated contact,
# since no select statement was given
#
# {
# ...
# "contactid": ...,
# "firstname": ...,
# "lastname": ...,
# ...
# }
### Example DELETE request
client.reset_query()
client.table = "contacts"
client.row_id = result["contactid"]
client.delete()
Metadata
Release files for dynamics-client 0.8.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dynamics_client-0.8.4.tar.gz | 40.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dynamics_client-0.8.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 86.7 kB
Release files / dynamics_client-0.8.4.tar.gz
| Download URL | dynamics_client-0.8.4.tar.gz |
|---|---|
| Size | 40.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d596ab2aa8ab145e9c1e93615489185a357e9f12c6ec6b67024eb8e69b5553b7
|
|
BLAKE2b-256 checksum How to use checksums |
c6437830909c45e599386d2c67d0a0ab862d83f316950ba0819bca4c56e76c74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure
|
Release files / dynamics_client-0.8.4-py3-none-any.whl
| Download URL | dynamics_client-0.8.4-py3-none-any.whl |
|---|---|
| Size | 46.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cd20adb8de106ffe6ee4d6ef798f17b4911defd78fded54ac0e9b8da2aaeebd
|
|
BLAKE2b-256 checksum How to use checksums |
4d1f976a81270e08a4978873dff56f4f84d571eca87fcde9fc45cab810b7f21d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure
|