Hi,
I am trying to create a new page under a space using the following code in nodejs:
var jsondata = { "type": "page", "title": "My Test Page", "space": { "key": "TEST" }, "body": { "wiki": { "value": "h1. Hello world!", "representation": "wiki" } }};
router.get('/content', (req, res) => {
axios.post(`${confluenceRootUri}/rest/api/content`, {
headers: {
'Content-Type': 'application/json; charset=utf-8',
"Authorization": "Basic " + Buffer.from(username + ":" + password).toString('base64')
},
data: JSON.stringify(jsondata)
})
.then(response => {
res.send(response.data);
})
.catch(error => {
res.status(error.status || 500);
res.send(error.response.data);
});
}
However I am getting the following bad request:
{
statusCode: 400,
data: {
authorized: true,
valid: false,
allowedInReadOnlyMode: true,
errors: [
{
message: {
key: "type is required to create content",
args: [ ]
}
}
],
successful: false
},
message: "Could not create content with type null",
reason: "Bad Request"
}
I also have tried the example from the website in python but it gives me syntax error
curl -u admin:admin -X POST -H 'Content-Type: application/json' -d '{"type":"page","title":"new page",
"space":{"key":"TST"},"body":{"storage":{"value":"<p>This is <br/> a new page</p>","representation":
"storage"}}}' http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool
What am I missing?