Skip to content

uptick/pybusinesscentral

Repository files navigation

pybusinesscentral

(v2.0) Business Central Standard APIs

PyPI version

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 2.0.0
  • Package version: 3.5.0
  • Generator version: 7.13.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

NOTE: Our OpenAPI spec file (bcoas2.0.yml) is modified from the original spec file located here. It only generates what we require, and fixes typing issues that cause invoice, credit note and purchase order bill interactions to fail on later versions of the openapi-generator because of the increased strictness in Pydantic v2.

Requirements.

Python 3.9+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import pybusinesscentral

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import pybusinesscentral

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import pybusinesscentral
from pybusinesscentral.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.businesscentral.dynamics.com/v2.0/sandbox/api/v2.0
# See configuration.py for a list of all supported configuration parameters.
configuration = pybusinesscentral.Configuration(
    host = "https://api.businesscentral.dynamics.com/v2.0/sandbox/api/v2.0"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]


# Enter a context with an instance of the API client
with pybusinesscentral.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pybusinesscentral.AccountApi(api_client)
    company_id = 'company_id_example' # str | (v1.0) id for company
    account_id = 'account_id_example' # str | (v1.0) id for account
    select = ['select_example'] # List[str] | (v1.0) Selected properties to be retrieved (optional)

    try:
        # Retrieve the properties and relationships of an object of type account for Dynamics 365 Business Central.
        api_response = api_instance.get_account(company_id, account_id, select=select)
        print("The response of AccountApi->get_account:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AccountApi->get_account: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.businesscentral.dynamics.com/v2.0/sandbox/api/v2.0

Class Method HTTP request Description
AccountApi get_account GET /companies({company_id})/accounts({account_id}) Retrieve the properties and relationships of an object of type account for Dynamics 365 Business Central.
AccountApi list_accounts GET /companies({company_id})/accounts Returns a list of accounts
CompanyApi get_company GET /companies({company_id}) Retrieve the properties and relationships of an object of type company for Dynamics 365 Business Central.
CompanyApi list_companies GET /companies Returns a list of companies
CustomerApi delete_customer DELETE /companies({company_id})/customers({customer_id}) Deletes an object of type customer in Dynamics 365 Business Central
CustomerApi get_customer GET /companies({company_id})/customers({customer_id}) Retrieve the properties and relationships of an object of type customer for Dynamics 365 Business Central.
CustomerApi list_customers GET /companies({company_id})/customers Returns a list of customers
CustomerApi patch_customer PATCH /companies({company_id})/customers({customer_id}) Updates an object of type customer in Dynamics 365 Business Central
CustomerApi post_customer POST /companies({company_id})/customers Creates an object of type customer in Dynamics 365 Business Central
DimensionApi get_dimension GET /companies({company_id})/dimensions({dimension_id}) Retrieve the properties and relationships of an object of type dimension for Dynamics 365 Business Central.
DimensionApi list_dimensions GET /companies({company_id})/dimensions Returns a list of dimensions
DimensionSetLineApi get_dimension_set_lines_for_sales_credit_memo_line GET /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines({salesCreditMemoLine_id})/dimensionSetLines Retrieve the properties and relationships of the list of dimensionSetLines for a salesCreditMemoLine.
DimensionSetLineApi get_dimension_set_lines_for_sales_invoice_line GET /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines({salesInvoiceLine_id})/dimensionSetLines Retrieve the properties and relationships of the list of dimensionSetLines for a salesInvoiceLine.
DimensionSetLineApi post_sales_credit_memo_dimension_set_line POST /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines({salesCreditMemoLine_id})/dimensionSetLines Creates an object of type dimensionSetLine in Dynamics 365 Business Central
DimensionSetLineApi post_sales_invoice_dimension_set_line POST /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines({salesInvoiceLine_id})/dimensionSetLines Creates an object of type dimensionSetLine in Dynamics 365 Business Central
PaymentTermApi delete_payment_term DELETE /companies({company_id})/paymentTerms({paymentTerm_id}) Deletes an object of type paymentTerm in Dynamics 365 Business Central
PaymentTermApi get_payment_term GET /companies({company_id})/paymentTerms({paymentTerm_id}) Retrieve the properties and relationships of an object of type paymentTerm for Dynamics 365 Business Central.
PaymentTermApi list_payment_terms GET /companies({company_id})/paymentTerms Returns a list of paymentTerms
PaymentTermApi patch_payment_term PATCH /companies({company_id})/paymentTerms({paymentTerm_id}) Updates an object of type paymentTerm in Dynamics 365 Business Central
PaymentTermApi post_payment_term POST /companies({company_id})/paymentTerms Creates an object of type paymentTerm in Dynamics 365 Business Central
PurchaseInvoiceApi delete_purchase_invoice DELETE /companies({company_id})/purchaseInvoices({purchaseInvoice_id}) Deletes an object of type purchaseInvoice in Dynamics 365 Business Central
PurchaseInvoiceApi get_purchase_invoice GET /companies({company_id})/purchaseInvoices({purchaseInvoice_id}) Retrieve the properties and relationships of an object of type purchaseInvoice for Dynamics 365 Business Central.
PurchaseInvoiceApi list_purchase_invoices GET /companies({company_id})/purchaseInvoices Returns a list of purchaseInvoices
PurchaseInvoiceApi patch_purchase_invoice PATCH /companies({company_id})/purchaseInvoices({purchaseInvoice_id}) Updates an object of type purchaseInvoice in Dynamics 365 Business Central
PurchaseInvoiceApi post_action_purchase_invoices POST /companies({company_id})/purchaseInvoices({purchaseInvoice_id})/Microsoft.NAV.post Performs the post action for purchaseInvoices entity
PurchaseInvoiceApi post_purchase_invoice POST /companies({company_id})/purchaseInvoices Creates an object of type purchaseInvoice in Dynamics 365 Business Central
PurchaseInvoiceLineApi delete_purchase_invoice_line_for_purchase_invoice DELETE /companies({company_id})/purchaseInvoices({purchaseInvoice_id})/purchaseInvoiceLines('{purchaseInvoiceLine_id}') Deletes an object of type purchaseInvoiceLine in Dynamics 365 Business Central
PurchaseInvoiceLineApi get_purchase_invoice_line_for_purchase_invoice GET /companies({company_id})/purchaseInvoices({purchaseInvoice_id})/purchaseInvoiceLines('{purchaseInvoiceLine_id}') Retrieve the properties and relationships of an object of type purchaseInvoiceLine for Dynamics 365 Business Central.
PurchaseInvoiceLineApi list_purchase_invoice_lines GET /companies({company_id})/purchaseInvoiceLines Returns a list of purchaseInvoiceLines
PurchaseInvoiceLineApi list_purchase_invoice_lines_for_purchase_invoice GET /companies({company_id})/purchaseInvoices({purchaseInvoice_id})/purchaseInvoiceLines Returns a list of purchaseInvoiceLines
PurchaseInvoiceLineApi patch_purchase_invoice_line_for_purchase_invoice PATCH /companies({company_id})/purchaseInvoices({purchaseInvoice_id})/purchaseInvoiceLines('{purchaseInvoiceLine_id}') Updates an object of type purchaseInvoiceLine in Dynamics 365 Business Central
PurchaseInvoiceLineApi post_purchase_invoice_line POST /companies({company_id})/purchaseInvoiceLines Creates an object of type purchaseInvoiceLine in Dynamics 365 Business Central
PurchaseInvoiceLineApi post_purchase_invoice_line_for_purchase_invoice POST /companies({company_id})/purchaseInvoices({purchaseInvoice_id})/purchaseInvoiceLines Creates an object of type purchaseInvoiceLine in Dynamics 365 Business Central
SalesCreditMemoApi delete_sales_credit_memo DELETE /companies({company_id})/salesCreditMemos({salesCreditMemo_id}) Deletes an object of type salesCreditMemo in Dynamics 365 Business Central
SalesCreditMemoApi get_sales_credit_memo GET /companies({company_id})/salesCreditMemos({salesCreditMemo_id}) Retrieve the properties and relationships of an object of type salesCreditMemo for Dynamics 365 Business Central.
SalesCreditMemoApi list_sales_credit_memos GET /companies({company_id})/salesCreditMemos Returns a list of salesCreditMemos
SalesCreditMemoApi patch_sales_credit_memo PATCH /companies({company_id})/salesCreditMemos({salesCreditMemo_id}) Updates an object of type salesCreditMemo in Dynamics 365 Business Central
SalesCreditMemoApi post_action_sales_credit_memos POST /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/Microsoft.NAV.post Performs the post action for salesCreditMemos entity
SalesCreditMemoApi post_and_send_action_sales_credit_memos POST /companies({company_id})/salesCreditMemos({salesCreditMemo_id}) Performs the postAndSend action for salesCreditMemos entity
SalesCreditMemoApi post_sales_credit_memo POST /companies({company_id})/salesCreditMemos Creates an object of type salesCreditMemo in Dynamics 365 Business Central
SalesCreditMemoLineApi delete_sales_credit_memo_line_for_sales_credit_memo DELETE /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines('{salesCreditMemoLine_id}') Deletes an object of type salesCreditMemoLine in Dynamics 365 Business Central
SalesCreditMemoLineApi get_sales_credit_memo_line_for_sales_credit_memo GET /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines('{salesCreditMemoLine_id}') Retrieve the properties and relationships of an object of type salesCreditMemoLine for Dynamics 365 Business Central.
SalesCreditMemoLineApi list_sales_credit_memo_lines GET /companies({company_id})/salesCreditMemoLines Returns a list of salesCreditMemoLines
SalesCreditMemoLineApi list_sales_credit_memo_lines_for_sales_credit_memo GET /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines Returns a list of salesCreditMemoLines
SalesCreditMemoLineApi patch_sales_credit_memo_line_for_sales_credit_memo PATCH /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines('{salesCreditMemoLine_id}') Updates an object of type salesCreditMemoLine in Dynamics 365 Business Central
SalesCreditMemoLineApi post_sales_credit_memo_line POST /companies({company_id})/salesCreditMemoLines Creates an object of type salesCreditMemoLine in Dynamics 365 Business Central
SalesCreditMemoLineApi post_sales_credit_memo_line_for_sales_credit_memo POST /companies({company_id})/salesCreditMemos({salesCreditMemo_id})/salesCreditMemoLines Creates an object of type salesCreditMemoLine in Dynamics 365 Business Central
SalesInvoiceApi delete_sales_invoice DELETE /companies({company_id})/salesInvoices({salesInvoice_id}) Deletes an object of type salesInvoice in Dynamics 365 Business Central
SalesInvoiceApi get_sales_invoice GET /companies({company_id})/salesInvoices({salesInvoice_id}) Retrieve the properties and relationships of an object of type salesInvoice for Dynamics 365 Business Central.
SalesInvoiceApi list_sales_invoices GET /companies({company_id})/salesInvoices Returns a list of salesInvoices
SalesInvoiceApi patch_sales_invoice PATCH /companies({company_id})/salesInvoices({salesInvoice_id}) Updates an object of type salesInvoice in Dynamics 365 Business Central
SalesInvoiceApi post_action_sales_invoices POST /companies({company_id})/salesInvoices({salesInvoice_id})/Microsoft.NAV.post Performs the post action for salesInvoices entity
SalesInvoiceApi post_sales_invoice POST /companies({company_id})/salesInvoices Creates an object of type salesInvoice in Dynamics 365 Business Central
SalesInvoiceLineApi delete_sales_invoice_line_for_sales_invoice DELETE /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines('{salesInvoiceLine_id}') Deletes an object of type salesInvoiceLine in Dynamics 365 Business Central
SalesInvoiceLineApi get_sales_invoice_line_for_sales_invoice GET /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines('{salesInvoiceLine_id}') Retrieve the properties and relationships of an object of type salesInvoiceLine for Dynamics 365 Business Central.
SalesInvoiceLineApi list_sales_invoice_lines GET /companies({company_id})/salesInvoiceLines Returns a list of salesInvoiceLines
SalesInvoiceLineApi list_sales_invoice_lines_for_sales_invoice GET /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines Returns a list of salesInvoiceLines
SalesInvoiceLineApi patch_sales_invoice_line_for_sales_invoice PATCH /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines('{salesInvoiceLine_id}') Updates an object of type salesInvoiceLine in Dynamics 365 Business Central
SalesInvoiceLineApi post_sales_invoice_line POST /companies({company_id})/salesInvoiceLines Creates an object of type salesInvoiceLine in Dynamics 365 Business Central
SalesInvoiceLineApi post_sales_invoice_line_for_sales_invoice POST /companies({company_id})/salesInvoices({salesInvoice_id})/salesInvoiceLines Creates an object of type salesInvoiceLine in Dynamics 365 Business Central
VendorApi delete_vendor DELETE /companies({company_id})/vendors({vendor_id}) Deletes an object of type vendor in Dynamics 365 Business Central
VendorApi get_vendor GET /companies({company_id})/vendors({vendor_id}) Retrieve the properties and relationships of an object of type vendor for Dynamics 365 Business Central.
VendorApi list_vendors GET /companies({company_id})/vendors Returns a list of vendors
VendorApi patch_vendor PATCH /companies({company_id})/vendors({vendor_id}) Updates an object of type vendor in Dynamics 365 Business Central
VendorApi post_vendor POST /companies({company_id})/vendors Creates an object of type vendor in Dynamics 365 Business Central

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

oAuth

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in pybusinesscentral.apis and pybusinesscentral.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1: Use specific imports for apis and models like:

  • from pybusinesscentral.api.default_api import DefaultApi
  • from pybusinesscentral.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import pybusinesscentral
from pybusinesscentral.apis import *
from pybusinesscentral.models import *

About

Python API for Business Central

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages