Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API create page return 500 No content to map to Object

Николай Войнов
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 2, 2021

Hi,

I want to export a tree of text nodes and build a page tree in the Confluence. I just started today to get to know REST API and got the first trouble. I'm using Ruby 3 and Excon for HTTP requests:

require 'json'
require 'excon'

site = "https://xyz.atlassian.net"
user = "me"
pass = "my_secret"

connection = Excon.new(site, user: user, password: pass)

# reqest for all pages works perfectly
response = connection.get(path: "/wiki/rest/api/space/DEMO/content/page")
JSON.parse(response.body)["results"].each do |page|
puts "id: #{page["id"]}; title: #{page["title"]}"
end

# but here I got 500
# statusCode\":500,\"message\":\"java.io.EOFException No content to map to Object due to end of in
response = connection.post(
path: "/wiki/rest/api/content",
headers: {
"Accept" => "application/json",
"Content-Type" => "application/json" },
data: JSON.generate(
"type" => "page",
"title" => "Ruby page",
"space" => {"key" => "DEMO"},
"status" => "current",
"body" => {
"storage" => {
"value" => "This is Ruby page",
"representation" => "view"
}
}
})
)

What is wrong with my parameters?

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events