Skip to main content

Simple DYN365 is a simple Microsoft Dynamics365 Web API client, it provides full CRUD functionality and eases use of Micorost Dynamics Web API, responses are returned in form of dictionary JSON.


More about Web API can be found at: https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/overview

Examples

There are two ways to gain access to Dynamics

The first is using client credentials which is to simply pass the CRM Org link, client ID, client Secret, TenantID

For example:

from simple_dyn365 import Dynamics
dyn = Dynamics(client_id='47xxxx37-xxxx-4837-bxx6-5fxxxx2a07e', client_secret='nb4gh5jtbKG.MWASDTU-bLqP~9YCFt-n', tenant_id='cxxxx58c-xxxx-4d8a-ac2e-1a8dxxxxfbb4', crm_org='https://myenvname.crm.dynamics.com')

For more information about this method and configuration of API user please refer to: Simple-dyn365 API Configuration

The second way is using password, as this feature is still to be implemented.

Record Management

To create a new ‘Contact’ in Dynamics:

dyn.contacts.create({'firstname' : 'Adam', 'email' : 'adam@adam-ma.dev'})

This will return a string of response such as 'https://myenvname.crm.dynamics.com/api/data/v9.2.21051.00140/contacts(96c5a6d3-28d3-eb11-bacc-000d3a57991e)'

To get a dictionary with all the information regarding that record, use:

contact = dyn.contacts.get('96c5a6d3-28d3-eb11-bacc-000d3a57991e')

To change that contact’s first name from ‘Adam’ to ‘John’ and add a last name of ‘Mahameed’ use:

dyn.contacts.update('96c5a6d3-28d3-eb11-bacc-000d3a57991e',{'firstname': 'John', 'lastname': 'Mahameed'})

To delete the contact:

dyn.contacts.delete('96c5a6d3-28d3-eb11-bacc-000d3a57991e')

Note that Update, Delete and Upsert actions return the associated HTTP status codes

Use the same format to create any record, including ‘accounts’, ‘contacts’, and ‘annotations’. Make sure to have all the required fields for any entry. The Web API has all entities and their fields.

Queries

It’s also possible to write select queries in Dynamics

Queries are done via:

dyn.query("contacts?$select=fullname,contactid")

It can also be done in the following way:

dyn.contacts.query("select=fullname,contactid")

Other Options

To retrieve basic metadata use:

dyn.contacts.metadata()

To upload Base64 object, use:

dyn.annotations.upload_base64(file_path='myimage.png', base64_field='documentbody' data={'subject' : 'Some subject', 'notetext' : 'Some text for the sweet note', 'objectid_contact@odata.bind' : 'contacts(02125b8c-9ed2-eb11-bacc-000d3a57991e)', 'filename' : 'myimage.png'})

To update Base64 object, use:

dyn.annotations.update_base64(entity_id='65bb00b9-99d2-eb11-bacc-000d3a57991e',base64_field='documentbody', file_path='newimg.png'))

To retrieve a Base64 object:

base64_data = dyn.annotations.get_base64('65bb00b9-99d2-eb11-bacc-000d3a57991e', base64_field='documentbody')
with open('img.png', 'wb') as f:
     f.write(base64_data)

Author & License

This package is released under MIT license. Simple-DYN365 was written by Adam Mahameed, its idea was taken from implementation of simple-salesforce REST API package.

GitHub

Release files for simple-dyn365 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-dyn365 1.6.1
File Size Uploaded
simple-dyn365-1.6.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simple-dyn365 1.6.1
File Interpreter ABI Platform
simple_dyn365-1.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / simple-dyn365-1.6.1.tar.gz

Download URL simple-dyn365-1.6.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3f9577a497e5987c705b5be735884cff818577b9d4be825d414768a36fb4df04
BLAKE2b-256 checksum
How to use checksums
cc14af3ff7c1d3e8af437fb0cb3a4229eb22a0e6211b592c619fdb0a2e73e3ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / simple_dyn365-1.6.1-py3-none-any.whl

Download URL simple_dyn365-1.6.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7de3f5dc7952ea23bd61175a7e56b6551cbb56d3338e832d7715550d2a16a22c
BLAKE2b-256 checksum
How to use checksums
03c79a9f9e423f9f0d13d3467538276583b93515821bf67682a51e99aff98733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.6.1 This release

2 release files

1.6

2 release files

1.5

2 release files

1.4

1 release file

1.2

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page