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.5.tar.gz
(27.1 kB
view details)
Built Distribution
File details
Details for the file dynamics-client-0.2.5.tar.gz
.
File metadata
- Download URL: dynamics-client-0.2.5.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22c43ab625f79f8c9c886e54c5aa191f12bbcfbdc204487e83eb62c0e06a5f84 |
|
MD5 | e2fd95ce9244d4aa55e2776e0a454434 |
|
BLAKE2b-256 | 1ae24cc5834792a2070e452e591824473ce7ddb73e9e158482fa5a0e3f17404f |
File details
Details for the file dynamics_client-0.2.5-py3-none-any.whl
.
File metadata
- Download URL: dynamics_client-0.2.5-py3-none-any.whl
- Upload date:
- Size: 31.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f29aa04b0171765a8e454e07d69fffd7109e8028778b53e75098f15ae67c8095 |
|
MD5 | 49e278e78981230d22f388601008d724 |
|
BLAKE2b-256 | 8252a24c1abdc5202626e7e77652e37d6bcb563963b5ed46038c9990e482427f |