K
Kinde2mo ago
Scott

Kinde API - "NAME_REQUIRED" error despite name being provided

Hi, I'm trying to call the create organization API but I'm getting stuck with a strange error. My code looks like this:
const headers = {
Accept: "application/json",
Authorization: `Bearer ${accessToken}`,
};

const response = await fetch(
`${process.env.KINDE_ISSUER_URL}/api/v1/organization`,
{
method: "POST",
headers,
body: JSON.stringify({
name,
handle: createHandle(name),
sender_email: email,
}),
}
);
const headers = {
Accept: "application/json",
Authorization: `Bearer ${accessToken}`,
};

const response = await fetch(
`${process.env.KINDE_ISSUER_URL}/api/v1/organization`,
{
method: "POST",
headers,
body: JSON.stringify({
name,
handle: createHandle(name),
sender_email: email,
}),
}
);
But I keep getting this error: [ { code: 'NAME_REQUIRED', message: 'Name is required' } ] I've even tried hard coding different values for the name field, but still get the same error. Any idea what I might be doing wrong? Thanks in advance!
5 Replies
Ages - Kinde
Ages - Kinde2mo ago
Hi Scott, Thanks for sharing the details. I'll check on my end to test and will get back to you with my findings soon. Hi Scott, I've just tested the create organization endpoint using the parameters as defined in the Kinde Management API documentation, and I'm receiving a 200 response, which confirms that our API is working as expected. Since you're encountering a "NAME_REQUIRED" error despite supplying the name value, I suggest double-checking the request payload that your code is actually sending. To help isolate the issue, could you add some logging right before your fetch call? Let me know what you find, and feel free to share the payload logs if the issue persists. I'll be happy to help further troubleshoot the issue
Scott
ScottOP2mo ago
Thanks for your help! I added console.log right before the fetch call to check what's being sent:
console.log(
JSON.stringify({
name,
handle: createHandle(name),
sender_email: email,
})
);
console.log(
JSON.stringify({
name,
handle: createHandle(name),
sender_email: email,
})
);
The logged output shows the correct data: {"name":"Hello World","handle":"hello_world","sender_email":"[email protected]"} So it looks like my variables contain the right values before the fetch. Any other troubleshooting steps you'd recommend?
Ages - Kinde
Ages - Kinde2mo ago
Hi Scott, Thanks for sharing the payload. I checked on my side using the same payload, and everything looks fine. I’ll check with my team regarding your specific account and update you as soon as I have more information Hi Scott, Can you try adding the "Content-Type": "application/json" header to your request and see if that resolves the issue? Here's how your headers should look:
const headers = {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
};
const headers = {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
};
Scott
ScottOP2mo ago
Hi Ages, adding the "Content-Type": "application/json" header fixed everything. The API call is working perfectly now. Really appreciate your help on this🙏
Ages - Kinde
Ages - Kinde2mo ago
Hi Scott, That's great to hear! I'm glad adding the "Content-Type": "application/json" header resolved the issue. Thanks for confirming. Please feel free to reach out if you need any further assistance.

Did you find this page helpful?