Can't figure out why I cant create a new page with rest api

curl -u myUser:myPassword -X POST -H ‘Content-Type: application/json’ -d ‘{“type”:“page”,“title”:“new page”,“space”:{“key”:“mySpaceKey”},“body”:{“storage”:{“value”:“<p>This is a newpage</p>”,“representation”:“storage”}}}’ http://myHost/rest/api/content/ | python -mjson.tool

username, password, space key, and host are all replaced. Is there anything else im missing that needs to be changed? Usually it says curl: (6) Could not resolve host: application and Expecting value: line 1 column 1 (char 0)

Hello @hberg

You haven’t said if you’re using Confluence SERVER or CLOUD.

Given that your cURL command contains -u myUser:myPassword and Confluence Cloud’s REST API doesn’t support Basic authentication with passwords, can it be assumed you’re connecting to a Confluence Server instance?

1 Like


Welcome to Developer Community.

Looking at your curl command, it’s likely you’re using an installed server instance, because all cloud REST API endpoints start with <yourhost>

That said, if you’re getting the error from curl of curl: (6) Could not resolve host: application and Expecting value: line 1 column 1 (char 0) then the hostname is not correct, as I can’t see anything else wrong with the command line.

Maybe try curl --verbose without the | python -mjson.tool and post the content here.

Hope this helps

1 Like

Yes, and I was able to call other cURL commands in a similar way, its just I can’t figure out what’s wrong with this one.

Hello, thanks for the reply. The host name that I am using works with other commands, such as the one to upload an attachment to a page. I changed http to https, and removed the python part, and now it only outputs
curl: (6) Could not resolve host: application

The REST API only communicates on one port. If port 80 (http) works for your other cURL commands, then changing to port 443 (https) will result in no response, hence the “Could not resolve host” error.

By default Confluence Server’s REST API communicates on port 443, not port 80, and it would a ‘bad thing’ if your Confluence admin had changed that, so I’m a bit sceptical that you’ve been able to interact with the REST API of your Confluence Server “in a similar way” on port 80 via other cURL connections.

Can you please provide a complete sample of one of your cURL requests that works, including the full host URL. Just redact the username:password.

1 Like

I got it to work. It was missing some -H “Cookie: amassivestringofcharacters” that generated when I tried making the curl command with . I also had to remove the “body” part, so something was wrong with that. I’ll now be working on how to get that in without it stopping the command from working.