Skip to content

Commit bf982c1

Browse files
authored
fix: add correct Content-Type for batch operation (#191)
1 parent d9d51bb commit bf982c1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/BatchRequestBuilder.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,23 @@ public function execute()
157157
$boundary = $this->generateBoundary();
158158
$batchContent = $this->buildBatchContent($boundary);
159159

160-
// Create a custom request for batch operation with proper content type
161-
$request = $this->client->request(
160+
// Store original custom headers to restore them after the batch request
161+
$originalHeaders = $this->client->getHeaders();
162+
163+
// Set the correct Content-Type header for batch requests
164+
$this->client->addHeader('Content-Type', "multipart/mixed; boundary={$boundary}");
165+
166+
// Create the batch request
167+
$response = $this->client->request(
162168
HttpMethod::POST,
163169
'$batch',
164170
$batchContent
165171
);
166172

167-
return $request;
173+
// Restore original custom headers for future requests
174+
$this->client->setHeaders($originalHeaders);
175+
176+
return $response;
168177
}
169178

170179
/**

0 commit comments

Comments
 (0)