Skip to content

Commit ceb37c0

Browse files
fix: add missing Content-Type header to POST requests (#144)
* fix: add missing Content-Type header to POST requests - Add Content-Type: application/json header to post() function - Fix header casing from X-Magic-Secret-key to X-Magic-Secret-Key - Update CHANGELOG.md with v2.8.1 release notes - Resolves 422 errors caused by FastAPI not parsing JSON body correctly * fix: add missing Content-Type header to POST requests - Add Content-Type: application/json header to post() function - Fix header casing from X-Magic-Secret-key to X-Magic-Secret-Key - Resolves 422 errors caused by FastAPI not parsing JSON body correctly
1 parent 3579330 commit ceb37c0

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# v2.8.1 (Thu Oct 02 2025)
2+
3+
#### 🐛 Bug Fix
4+
5+
- Add missing Content-Type header to POST requests to fix 422 errors ([@damianjachyra](https://github.com/damianjachyra))
6+
- Fix header casing from X-Magic-Secret-key to X-Magic-Secret-Key ([@damianjachyra](https://github.com/damianjachyra))
7+
8+
#### Authors: 1
9+
10+
- Damian Jachyra ([@damianjachyra](https://github.com/damianjachyra))
11+
12+
---
13+
114
# v2.8.0 (Fri Sep 12 2025)
215

316
#### 🚀 Enhancement

src/utils/rest.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export function post<TBody extends Record<string, string | number | boolean>, TR
3838
) {
3939
return emitRequest<TResponse>(url, {
4040
method: 'POST',
41-
headers: { 'X-Magic-Secret-key': secretApiKey },
41+
headers: {
42+
'X-Magic-Secret-Key': secretApiKey,
43+
'Content-Type': 'application/json'
44+
},
4245
body: JSON.stringify(body),
4346
});
4447
}
@@ -50,6 +53,6 @@ export function get<TResponse>(url: string, secretApiKey: string, params?: any)
5053
const urlWithParams = generateQuery(url, params);
5154
return emitRequest<TResponse>(urlWithParams, {
5255
method: 'GET',
53-
headers: { 'X-Magic-Secret-key': secretApiKey },
56+
headers: { 'X-Magic-Secret-Key': secretApiKey },
5457
});
5558
}

test/spec/utils/rest/get.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('Successfully GETs to the given endpoint & stringifies query params', async
2121
'https://example.com/hello/world?foo=hello&bar=world',
2222
{
2323
method: 'GET',
24-
headers: { 'X-Magic-Secret-key': API_KEY },
24+
headers: { 'X-Magic-Secret-Key': API_KEY },
2525
},
2626
]);
2727
});
@@ -39,7 +39,7 @@ test('Successfully GETs to the given endpoint with no query params', async () =>
3939
'https://example.com/hello/world',
4040
{
4141
method: 'GET',
42-
headers: { 'X-Magic-Secret-key': API_KEY },
42+
headers: { 'X-Magic-Secret-Key': API_KEY },
4343
},
4444
]);
4545
});

test/spec/utils/rest/post.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ test('Successfully POSTs to the given endpoint & stringifies body', async () =>
2626
'https://example.com/hello/world',
2727
{
2828
method: 'POST',
29-
headers: { 'X-Magic-Secret-key': API_KEY },
29+
headers: {
30+
'X-Magic-Secret-Key': API_KEY,
31+
'Content-Type': 'application/json'
32+
},
3033
body: '{"public_address":"0x0123"}',
3134
},
3235
]);

0 commit comments

Comments
 (0)