I am having problems with PostBatchAsync batch updates: should be two '\r\n' between sub-request
ByYogi opened this issue · 2 comments
ByYogi commented
"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 commented
bgmulinari commented
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).