B1SLayer icon indicating copy to clipboard operation
B1SLayer copied to clipboard

I am having problems with PostBatchAsync batch updates: should be two '\r\n' between sub-request

Open ByYogi opened this issue 10 months ago • 2 comments

"Incomplete request, Please check if the sub-request has complete request content and there should be two '\r\n' between sub-request header and content!"

using B1SLayer;
var serviceLayer = new SLConnection("https://***:10000/b1s/v2", "***", "***", "***");

List<SLBatchRequest> batchReq = new List<SLBatchRequest>();

batchReq.Add(new SLBatchRequest(new HttpMethod("Patch"), $"Items('{"$creation"}')", new
{
    ItemCode = "$creation",
    ItemName = "Test Item1"
})); batchReq.Add(new SLBatchRequest(new HttpMethod("Patch"), $"Items('{"$creation2"}')", new
{
    ItemCode = "$creation2",
    ItemName = "Test Item2"
}));
HttpResponseMessage[] batchResult = await serviceLayer.PostBatchAsync(batchReq);

ByYogi avatar Apr 19 '24 05:04 ByYogi

I also get an error when I use the README example.

B1SLayer.SLException: 'Content ID should be specified in each change set request.'

image image

ByYogi avatar Apr 19 '24 06:04 ByYogi

Hi, @ByYogi.

When using OData V4 protocol (indicated by the 'v2' in your Service Layer URL), you are required to specify the content ID in all requests within a batch, even if you don't use it. Check the Service Layer User Manual regarding this topic.

Try changing your URL to 'v1' or specify the content ID in each request object (optional constructor parameter for the SLBatchRequest class).

bgmulinari avatar Apr 19 '24 12:04 bgmulinari