I have the following problem: I want to create a workspace on the bird.com service using their api, but I get a message when I create it:
{
code: 'InternalServerError',
message: 'An unexpected error has occurred'
}
I have a valid api key that allows me to perform manipulations in this domain. Everything happens in this code:
const createWorkspace = async (organizationId, name, region) => {
try {
const response = await axios.post(
`${BIRD_BASE_URL}/organizations/${organizationId}/workspaces`,
{
name,
description: name,
dataPolicy: {
group: region.group,
regions: [
{
region: region.region,
priority: 0,
},
],
},
},
{
headers: {
Authorization: `Bearer ${BIRD_API_KEY}`,
'Content-Type': 'application/json',
},
}
);
return response.data;
} catch (error) {
console.error('Error creating workspace:', error.response.data);
return null;
}
};
I created an apiKey, got the regions, and am using the following test router:
router.get('/', async (req, res) => {
const status = await createWorkspace(
BIRD_ORGANIZATION_ID,
'testEU',
birdRegion.eu
);
res.json(status);
});
birdRegion:
const birdRegion = {
eu: {
group: 'eu',
region: 'eu-west-1',
},
ap: {
group: 'ap',
region: 'ap-south-1',
},
us: {
group: 'us',
region: 'us-west-1',
},
};
and have next request body:
{
"name": "testEU",
"description": "testEU",
"dataPolicy": {
"group": "eu",
"regions": [
{
"region": "eu-west-1",
"priority": 0
}
]
}
}
Bird.com docs:
const response = await fetch('/organizations/{organizationId}/workspaces', {
method: 'POST',
headers: {
"Authorization": "Bearer jwt",
"Content-Type": "application/json"
},
body: JSON.stringify({
"name": "text",
"dataPolicy": {
"group": "eu",
"regions": [
{
"region": "eu-west-1"
}
]
}
}),
});
const data = await response.json();