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.3.0.tar.gz
(34.1 kB
view details)
Built Distribution
File details
Details for the file dynamics-client-0.3.0.tar.gz
.
File metadata
- Download URL: dynamics-client-0.3.0.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abfb7b8d5d818e8ed957d09699d25309d1c360f682044205cffab6e3693c4afa |
|
MD5 | c0469745ec0fe6aa6df3cfaf8994274f |
|
BLAKE2b-256 | db8bb1d42c3d6e3652707685784ed7f7d7d0f419da36660f25c930f66971876b |
File details
Details for the file dynamics_client-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: dynamics_client-0.3.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e51e78c4a7c6a5653d64fc82c5e5d65f4af71e2447d561ebf24c31541ce8e4d2 |
|
MD5 | 0f33ecef4627a5d1e4a876f2b96c9bbf |
|
BLAKE2b-256 | 4e96079058b24b2ac4ff020b6190cac7dac865e6f6e420b6d12626e09f3af29d |