bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET
MIT License
122 stars 42 forks source link

Specifying custom headers on SLConnection #74

Open EricWu91 opened 1 month ago

EricWu91 commented 1 month ago

Sorry for the barrage of questions :)

As specified here (https://community.sap.com/t5/enterprise-resource-planning-q-a/service-layer-how-to-remove-all-addresses-of-a-business-partner/qaq-p/578058), whenever I want to clear the collections of a PATCH request (e.g. Business Partners' addresses), I'm required to provide a specific header: B1S-ReplaceCollectionsOnPatch=true

Is there a way to do that in SLConnection?

bgmulinari commented 1 month ago

Hi, @EricWu91.

Yes, you can call WithReplaceCollectionsOnPatch extension method in your request to add this header.

await serviceLayer
    .Request("BusinessPartners", "C00001")
    .WithReplaceCollectionsOnPatch()
    .PatchAsync(yourObject);
EricWu91 commented 1 month ago

Sweet! Sorry if it was obvious. Did I miss a doc pointing that out?

bgmulinari commented 1 month ago

Not really, I'm yet to write a proper documentation for B1SLayer. I'll start that once 2.0 is out :)

EricWu91 commented 1 month ago

Ok! If you need, I can help you with that. Just create an issue and mention me and I'll do what I can.