From 199104dc23679b4e7cbf13ae22414e3e15b1720d Mon Sep 17 00:00:00 2001 From: Duc Tran Date: Tue, 4 Nov 2025 14:26:44 +0100 Subject: [PATCH] fix: add correct Content-Type for batch operation --- src/BatchRequestBuilder.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/BatchRequestBuilder.php b/src/BatchRequestBuilder.php index dcbc550..4854408 100644 --- a/src/BatchRequestBuilder.php +++ b/src/BatchRequestBuilder.php @@ -157,14 +157,23 @@ public function execute() $boundary = $this->generateBoundary(); $batchContent = $this->buildBatchContent($boundary); - // Create a custom request for batch operation with proper content type - $request = $this->client->request( + // Store original custom headers to restore them after the batch request + $originalHeaders = $this->client->getHeaders(); + + // Set the correct Content-Type header for batch requests + $this->client->addHeader('Content-Type', "multipart/mixed; boundary={$boundary}"); + + // Create the batch request + $response = $this->client->request( HttpMethod::POST, '$batch', $batchContent ); - return $request; + // Restore original custom headers for future requests + $this->client->setHeaders($originalHeaders); + + return $response; } /**