Hello @Louraine
You need to pass the headers object as the second argument to axios.post, not as part of the data object. So your code should look like this:
const publishTable = async auth => {
return await axios.post(
`${HUBDB_API}/${HUBDB_TABLE_ID}/draft/publish`,
{},
{
headers: {
"Accept": "application/json",
'Content-Type' : 'application/json',
'Authorization' : `Bearer ${BIAPIKEY}`
}
}
);
}
Then, the draft/publish endpoint is not a valid endpoint in the HubDB API. Instead, you should use the draft/push-live endpoint to publish a draft version of a table. So your code should look like this:
const publishTable = async auth => {
return await axios.post(
`${HUBDB_API}/${HUBDB_TABLE_ID}/draft/push-live`,
{},
{
headers: {
"Accept": "application/json",
'Content-Type' : 'application/json',
'Authorization' : `Bearer ${BIAPIKEY}`
}
}
);
}
Make sure you have the necessary permissions and access to perform the publish action. Also, ensure that you have provided the correct HUBDB_API, HUBDB_TABLE_ID, and BIAPIKEY values.
Thanks & Regards
Himanshu Rauthan