bc_webservices

Authentication and connectivity to Microsoft Dynamics 365 Business Central Web Services

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 0.1.12
License GPL-3.0-only
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:26

Authors

  • Paul Wilde

Installation

nimble install bc_webservices
choosenim install bc_webservices
git clone https://codeberg.org/pswilde/bc_webservices

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
bc_webservices - - - - - - -

Dependencies

Package Version Optional
nim >= 1.6.0 No
jsony >= 1.1.5 No

Source

Repository https://codeberg.org/pswilde/bc_webservices
Homepage https://codeberg.org/pswilde/bc_webservices
Registry Source nimble_official

README

Nim BC Webservices

A basic tool to handle authentication and requests made to Microsoft Dynamics 365 Business Central.
This is still a work in progress. Although it does work, and can be used to get data from Business Central, it is still early days to there may be some bugs

Installation

nimble install bc_webservices
````
or add `requires "bc_webservices"` to your .nimble file

then import by
```nim
import bc_webservices 

How to use

  1. Get your company_secret and client_id from the MS Azure API App Registrations page
  2. Setting up Azure Active Directory (Azure AD) based authentication
  3. Also make note of your scope url, normally something like "https://api.businesscentral.dynamics.com/.default"
  4. Use those details, plus your tenant_id, environment, and company to build up an authentication config. There's a bcAuth var available to store this info i.e. nim bcAuth = Auth() bcAuth.client_id = client_id bcAuth.company_secret = company_secret bcAuth.tenant_id = tenant_id bcAuth.environment = environment bcAuth.company = company bcAuth.scope = "https://api.businesscentral.dynamics.com/.default" see test_auth.nim in tests for an example
  5. You can see your available endpoint names in either the Web Services card in Business Central OR by running getAvailableEndpoints() in this library

The preferred method is to use the odataRequest procedure like so

import bc_webservices as bc

bcAuth = Auth()
# ... get auth details as above ...

# make a request to OData name
var ws = WebService()
ws.name = "workflowCustomers"
# add filters if you want
ws.filter = "balance gt 0"
# and/or select items
ws.select = "name,balance"
# spaces in filters will automatically replaced with %20
let resp = odataRequest(ws)
if resp.status == $Http200:
  let data = resp.body.fromJson() 
  for item in data["value"]:
      # Do something...

# OR request to an API URL
var ws = WebService()
ws.name = "customers"
# add filters if you want
ws.filter = "balance gt 0"
# and/or select items
ws.select = "name,balance"
let resp = getRequest(ws)
if resp.status == $Http200:
   # ...

or you can just use odataRequest with a full url string

import bc_webservices as bc

bcAuth = Auth()
# ... get auth details as above ...

let resp = odataRequest(really_long_odata_url_with_filters_and_stuff)
# ...

Filter documentation is at Using Filters with OData/API calls. This library automatically adds the "?$filter=" and replaces spaces with "%20"

Issues

Please raise an issue here if you find anything that is not working correctly