### Perform GET Request with Query Parameters Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Retrieves a list of business partners with filtering, selection, ordering, and pagination. Supports case-insensitive matching and custom page sizes. ```csharp // Performs a GET on /BusinessPartners with query string and header parameters supported by Service Layer // The result is deserialized in a List of a custom model class var bpList = await serviceLayer.Request("BusinessPartners") .Filter("startswith(CardCode, 'c')") .Select("CardCode, CardName") .OrderBy("CardName") .WithPageSize(50) .WithCaseInsensitive() .GetAsync>(); ``` -------------------------------- ### Retrieve All Items Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Fetches all entities of a resource, such as 'Items', by making multiple GET requests until all records are obtained. The result is an unwrapped list. ```csharp // Performs a GET on /Items until all entities in the database are obtained // The result is an IList of your custom model class (unwrapped from the 'value' array) var allItemsList = await serviceLayer.Request("Items").GetAllAsync(); ``` -------------------------------- ### Perform GET Request for a Single Order Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Retrieves a specific order by its ID and deserializes the response into a custom model class. This is a basic GET operation on a resource. ```csharp // Performs a GET on /Orders(823) and deserializes the result in a custom model class var order = await serviceLayer.Request("Orders", 823).GetAsync(); ``` -------------------------------- ### Perform GET Request with Composite Primary Key Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Retrieves a record using a composite primary key for resources like AlternateCatNum. The key is specified as a string within the request. ```csharp // Performs a GET on /AlternateCatNum specifying the record through a composite primary key var altCatNum = await serviceLayer .Request("AlternateCatNum(ItemCode='A00001',CardCode='C00001',Substitute='BP01')") .GetAsync(); ``` -------------------------------- ### Perform PATCH Request to Update a Business Partner Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Updates a specific business partner by sending a partial object containing the fields to be modified in a PATCH request. This example updates the CardName. ```csharp // Performs a PATCH on /BusinessPartners('C00001'), updating the CardName of the Business Partner await serviceLayer.Request("BusinessPartners", "C00001") .PatchAsync(new { CardName = "Updated BP name" }); ``` -------------------------------- ### Initialize Service Layer Connection Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Establishes a connection to the SAP Business One Service Layer. The connection object manages session automatically and does not require manual login. Use one instance per company/user. ```csharp var serviceLayer = new SLConnection("https://sapserver:50000/b1s/v1", "CompanyDB", "manager", "12345"); ``` -------------------------------- ### Perform POST Request to Create an Order Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Creates a new order by sending an object as the JSON body in a POST request. The newly created order is then deserialized into a custom model class. ```csharp // Performs a POST on /Orders with the provided object as the JSON body, // creating a new order and deserializing the created order in a custom model class var createdOrder = await serviceLayer.Request("Orders").PostAsync(myNewOrderObject); ``` -------------------------------- ### Perform POST Request to Upload Attachment Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Uploads a file as an attachment to the Service Layer. The file path is provided, and the attachment details are returned. ```csharp // Performs a POST on /Attachments2 with the provided file as the attachment var attachmentEntry = await serviceLayer.PostAttachmentAsync(@"C:\files\myfile.pdf"); ``` -------------------------------- ### Perform PATCH Request to Update Item Image Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Adds or updates an item image using a PATCH request. This method is suitable for binary data like images, specifying the file path. ```csharp // Performs a PATCH on /ItemImages('A00001'), adding or updating the item image await serviceLayer.Request("ItemImages", "A00001") .PatchWithFileAsync(@"C:\ItemImages\A00001.jpg"); ``` -------------------------------- ### Perform Batch Requests Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Executes multiple Service Layer operations (POST, PATCH, DELETE) within a single HTTP request for efficiency. Each operation is defined as an SLBatchRequest object. ```csharp // Batch requests! Performs multiple operations in SAP in a single HTTP request var req1 = new SLBatchRequest( HttpMethod.Post, // HTTP method "BusinessPartners", // resource new { CardCode = "C00001", CardName = "I'm a new BP" }) // object to be sent as the JSON body .WithReturnNoContent(); // Adds the header "Prefer: return-no-content" to the request var req2 = new SLBatchRequest(HttpMethod.Patch, "BusinessPartners('C00001')", new { CardName = "This is my updated name" }); var req3 = new SLBatchRequest(HttpMethod.Delete, "BusinessPartners('C00001')"); HttpResponseMessage[] batchResult = await serviceLayer.PostBatchAsync(req1, req2, req3); ``` -------------------------------- ### Perform Logout Source: https://github.com/bgmulinari/b1slayer/blob/dev/README.md Ends the current Service Layer session by performing a POST request to the /Logout endpoint. This should be called when the application is closing or the session is no longer needed. ```csharp // Performs a POST on /Logout, ending the current session await serviceLayer.LogoutAsync(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.