Hello Community,
I am trying to create a new Space in my Confluence using REST API. I am using the following commands:
POST: https://<<my Confluence>>.atlassian.net/wiki/rest/api/content/
JSON Body:
{
"key":"MKT",
"name":"Marketing",
"homepage":{
"body":{
"storage":{
"value":"<p>This is the updated text for the new page</p>",
"representation":"storage"
}
}
},
"metadata":{}
}
I am using basic Authentification. Unfortunately, Postman returns the following:
{ "statusCode": 400, "data": { "authorized": true, "valid": false, "errors": [ { "message": { "key": "type is required to create content", "args": [] } } ], "successful": false }, "message": "com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not create content with type null"}
Unfortunately I cannot see which kind of "type" is required and where I can set it.
Thank you very much for your help and have a nice day.
Hi Benjamin,
The endpoint you're hitting is to create a page (or some other single piece of content) vs a space (the container that content sits in). For that endpoint, the type field specifies if it's a regular page, a blogpost, etc. From the API documentation:
type REQUIRED
string
The type of the new content. Custom content types defined by apps are also supported.
Valid values:page
,blogpost
,comment
,attachment
If you're trying to create a space and not a page (as I suspect you are, from what's in your current call), you'll instead want to use the /wiki/rest/api/space endpoint. Documentation for that endpoint is available here and it looks like your request contains all the required parameters.
Cheers,
Daniel
Hello Daniel,
thank you very much for your answer.
Best regards,
Benjamin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.