Posted on 03/06/2026 12:48:42
Hi Imar
I am building a connection to BC using endpoints - if you have access to devops it is here: https://dev.azure.com/dynamicwebsoftware/Dynamicweb/_git/Dynamicweb10/pullrequest/21346
Below is a code example that can get you started:
There's an existing HttpRestClient in the OData provider infrastructure, but it's internal to Dynamicweb.DataIntegration, so you can't use it directly from your own module. The cleanest approach is the same pattern the BC invoice module above uses: pull the Endpoint from EndpointService and call auth.AddIn.PrepareClient() yourself. All the auth plumbing is there — you just need to wire it together.
Here's the minimal version, using the same low-level calls that HttpRestClient uses internally:
The simplest approach — use EndpointService directly
using System;
using System.Net.Http;
using Dynamicweb.DataIntegration.EndpointManagement;
using Dynamicweb.Scheduling;
using Dynamicweb.Extensibility.AddIns;
[AddInName("FoImportScheduledTask")]
[Schedule(ScheduleInterval.Daily)]
public class FoImportScheduledTask : ScheduledTask
{
[AddInParameter("Endpoint ID")]
[AddInParameterEditor(typeof(IntegerParameterEditor), "")]
public int EndpointId { get; set; }
public override bool Execute()
{
var endpointService = new EndpointService();
var endpoint = endpointService.GetEndpointById(EndpointId)
?? throw new InvalidOperationException($"Endpoint {EndpointId} not found.");
using var handler = new HttpClientHandler { CheckCertificateRevocationList = true };
using var client = new HttpClient(handler);
// This applies OAuth2, bearer tokens, certificates — whatever is configured on the endpoint
var auth = endpoint.Authentication;
if (auth?.AddIn is not null && !string.IsNullOrEmpty(endpoint.Url))
auth.AddIn.PrepareClient(new Uri(endpoint.Url), client, handler, endpoint);
// Build your F&O custom endpoint URL
var url = endpoint.Url.TrimEnd('/') + "/your/custom/path";
var json = client.GetStringAsync(url).GetAwaiter().GetResult();
// Steps 3-5: your JSON→XML conversion, save, and import job
ProcessJson(json);
return true;
}
}
That's it. EndpointService is in Dynamicweb.DataIntegration.EndpointManagement — the same assembly that drives the OData provider.
If you want to reuse more of the OData infrastructure
The OData provider stack (HttpRestClient, ODataSourceReader, etc.) is all internal, so it's not directly reusable. But if your F&O endpoint follows the standard OData $metadata / entity set conventions, you could configure a standard OData Provider job in Data Integration pointing at the F&O endpoint and skip writing HTTP code entirely — the DI job handles the connection, auth, pagination, and XML/staging table output for you.
If the endpoint is a custom non-OData REST endpoint, the manual EndpointService pattern above is the right approach.
Key types
|
What you need
|
Type
|
Namespace
|
|
Look up the endpoint by ID
|
EndpointService.GetEndpointById(int)
|
Dynamicweb.DataIntegration.EndpointManagement
|
|
Apply auth (OAuth, certs, etc.)
|
endpoint.Authentication.AddIn.PrepareClient(...)
|
same
|
|
Your task base class
|
ScheduledTask
|
Dynamicweb.Scheduling
|
The existing reference for the PrepareClient pattern is BcEndpointProvider.cs on the above branch.