Is it possible to get org code from the response after adding a organization via management api
I am able to successfully add organization via kinde's management api. However, i need to get the org_code to insert into my database via prisma. I looked at the response from calling the https://apps.kinde.com/api/v1/organization api and it just return the status, statusText, body etc but there is no mention of the org_code created. Can someone advise me on this? Thanks
4 Replies
https://docs.kinde.com/kinde-apis/management/#tag/organizations/post/api/v1/organization provides the organisation code in the response for a
200
response.
I'm not using the API directly but through the .NET SDK which is just a wrapper around the API it provides me with the org code in the response.Kinde docs
Kinde Management API
The management API is for managing your Kinde account. Most things that can be done via the Kinde admin UI can be done with this API
Thanks a lot Stephen. I get a 200 response but i don't see the org_code in the response. below is my code
const res = await fetch(url, {
method: "POST",
body: JSON.stringify({
name: company,
}),
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization:
Bearer ${accessToken}
,
},
});
console.log("res", res);
res Response {
status: 200,
statusText: 'OK',
headers: Headers {
date: 'Thu, 02 Jan 2025 01:02:05 GMT',
'content-type': 'application/json; charset=utf-8',
'content-length': '82',
connection: 'keep-alive',
vary: 'Accept-Encoding'
},
body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
bodyUsed: false,
ok: true,
redirected: false,
type: 'basic',
url: 'https://apps.kinde.com/api/v1/organization'
}You need to read the stream (body) I believe.
I'm not familar with Prisma, but it might be easier to use one of Kinde's SDKs. That said, there's no reason you can't use
fetch
directly via JavaScript.you are a genius bro! you are right. i need to run json() to get the org code. thanks a lot. below is that portion of the code in case someone faces the same issue.
const output = await res.json(); console.log("output", output?.organization.code);
const output = await res.json(); console.log("output", output?.organization.code);