bgmulinari / B1SLayer

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

Patch Address in BusinessPartners #30

Closed JorgeNT1981 closed 1 year ago

JorgeNT1981 commented 1 year ago

Good morning, I'm having trouble when I want to patch Address in BusinessParterns, here some code:

In Postman works, modified the rowNum (0) :

BusinessPartners(CardCode = 'C1801123') { "BPAddresses": [ { "RowNum": 0, "AddressName": "Bill To", "Street": "calle 4665", "Country": "BO", "FederalTaxID": "34343434", "TaxCode": "IVA_ICE", "AddressType": "bo_BillTo", "AddressName2": "Test", "AddressName3": "Test", "BPCode": "C1801123" } ] }

but whit this code, create another RowNum:

var Direcciones = new { CardName = bp.CardName, BPAddresses = new List() { new { RowNum = 0, AddressName = "Bill To", AddressName2 = "test", AddressName3 = "test", Street = "", TaxCode = "IVA", Country = "BO", StreetNo = "test", FederalTaxID = "test" } } }; await _serviceLayerConn .Request($"BusinessPartners(CardCode = '{bp.CardCode}')") .PatchAsync(Direcciones);

Any Ideas?

bgmulinari commented 1 year ago

Hi, @JorgeNT1981. Can you provide more details on your problem?

Usually for patching collections you need to pass the B1S-ReplaceCollectionsOnPatch=true header on the request. This can be done in B1SLayer through the WithReplaceCollectionsOnPatch extension method.

JorgeNT1981 commented 1 year ago

Thank you @bgmulinari for the quick response. I used WithReplaceCollectionsOnPatch and it worked fine.