Client for making Web API request from a Microsoft Dynamics 365 Database.
Project description
Dynamics Web API Client
pip install dynamics-client
Documentation: https://mrthearman.github.io/dynamics-client/
Source Code: https://github.com/MrThearMan/dynamics-client
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()
# [
# {
# "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)
# {
# "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)
# 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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dynamics-client-0.2.3.tar.gz
(25.4 kB
view details)
Built Distribution
File details
Details for the file dynamics-client-0.2.3.tar.gz
.
File metadata
- Download URL: dynamics-client-0.2.3.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25b28e5a3bed153af888eb8dfab6f1a1ec5725707a2587edf7010ae39c56db91 |
|
MD5 | fc98d5d9d9d7622c8cc03836e71a370e |
|
BLAKE2b-256 | 72eaf963c98d68b3b78f56ddd9ccfd0f476e86bfca0ee28aee41323a40072159 |
File details
Details for the file dynamics_client-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: dynamics_client-0.2.3-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6a57768fbc00ae443260afba7ba957d74a120ed7130275f368ffd171dc5a781 |
|
MD5 | 630c8271f824162b9310dbaa72309ce1 |
|
BLAKE2b-256 | d24bc1cb206a048e1d0b98277e4af8d6a2b332df216e7cfb293f9cc1a36b1d38 |