0

I am trying to run this command

curl -u admin:admin -X POST -H 'Content-Type:application/json' -d'{"type":"page","title":"new page","space":{"key":"~SPACENAME"},"body":{"storage":{"value":"<p>This is <br/>a new page</p>","representation": "storage"}}}'  http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool

I have replaced admin:admin with my credentials ~SPACENAME with my spacename and the link, with my confluence link.

I am on windows, so I am using the command line.

The code above throws this error:

curl: (3) unmatched close brace/bracket in URL position 8:
storage}}}'
       ^
Expecting value: line 1 column 1 (char 0)

I am assuming this is due to windows command line having issues with ' sign. I read, that one can just try deleting it, so I did, and tried this command:

curl -u admin:admin -X POST -H Content-Type:application/json -d{"type":"page","title":"new page","space":{"key":"~SPACENAME"},"body":{"storage":{"value":"<p>This is <br/>a new page</p>","representation": "storage"}}}  http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool

which throws me this error:

{
    "statusCode": 500,
    "message": "",
    "reason": "Internal Server Error"
}

Now I managed to create my page with powershell, by using this command:

$authHeader = @{Authorization="Basic "+[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("admin:admin"))}; $jsonBody = @{type="page"; title="new page"; space=@{key="~SPACENAME"}; body=@{storage=@{value="<p>This is <br/>a new page</p>"; representation="storage"}}} | ConvertTo-Json; $response = Invoke-RestMethod -Uri "http://localhost:8080/confluence/confluence/rest/api/content/" -Method Post -Headers $authHeader -ContentType "application/json" -Body $jsonBody; $response | ConvertTo-Json

However, official wiki is not written for powershell, so I am afraid, that I will encounter other issues in the future. Would anyone know, what's wrong with my command line code?

P.s. I read this post but did not find a solution to my problem.

0 Answers0