Hi,
I am using the below command to extract the data from the confluence server
curl -u user:"passkey" -X GET "https://confluence.sw.mycompany.com/pages/viewpage.action?pageId=127798346" | python -mjson.tool
This command though it extracts but while piping it to the python json format converter it is giving an error as show here:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 79367 0 79367 0 0 50295 0 --:--:-- 0:00:01 --:--:-- 50295
Expecting value: line 2 column 1 (char 5)
However if I redirect the output of the curl command to a text file, I get the html content.
Could you please help me resolve this error.
My assumption: The confluence server is returning a html output, which python is treating as a byte array instead of strings so it is giving this error.
Please check and let me know.
I have followed the example available here:
https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/
curl -u admin:admin -X GET "http://localhost:8080/confluence/rest/api/content?type=blogpost&start=0 &limit=10&expand=space,history,body.view,metadata.labels" | python -mjson.tool
Welcome to Community! If you're accessing via API endpoint from here https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/ , the output should be in JSON and not HTML. However you should check the directory Confluence is installed, does yours say
http://localhost:8080/confluence/rest/api/content
or something else as "/confluence" is the directory where Confluence is installed on the Doc's example. if yours is a different directory, then you might want to change that in order to get the output. You can run a test of the URL on your Browser to see the output first, before attempting the curl extraction.
Hi Prince,
Thank you for your response!
I am a novice in the confluence programming, could you please elaborate where I have to check the installation of the confluence directory? Is it on the server? Because I have not installed the server by myself and it is taken care by the IT department in my organization (Who seems to have no clue on how to check this)
And also when I performed the following URL test on my browser
https://confluence.sw.mycompany.com/rest/api/content
I get huge content like this
{"results":[{"id":"2064464","type":"page","status":"current","title":"FRANS Home","extensions":{"position":"none"},"_links":{"webui":"/display/~beq03163/Frans+De+Buys%27s+Home","edit":"/pages/resumedraft.action?draftId=2064464","tinyui":"/x/UIAf","self":"https://confluence.sw.mycompany.com/rest/api/content/2064464"},"_expandable":
Please help, does it mean i am getting the output in JSON format?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the URL https://confluence.sw.mycompany.com/rest/api/content you should use instead, since that url works. so your request should be
curl -u user:password -X GET "https://confluence.sw.mycompany.com/rest/api/content?type=blogpost&start=0 &limit=10&expand=space,history,body.view,metadata.labels" | python -m json.tool
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for this information.
If i understand correctly, the following fields which are there as part of the URL shall be replaced by the page that i am interested in, istn't?
/content?type=blogpost&start=0 &limit=10&expand=space,history,body.view,metadata.labels"
i.e, blogpost and space with actual names used in the confluence page.?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This "space,history,body.view,metadata.labels" you do not need to change as you're expanding the json. if you need a specific page, use CQL "rest/api/content/search?cql=space=TEST" mentioned on Advanced searching.
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.
Glad to help out, if the above answers your question. Please accept the answer, so other users can see it as a solution.
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.
Hi @Prince Nyeche
I'm totally new to using rest api for confluence. Can you please help me with this
https://community.atlassian.com/t5/Jira-questions/PowerShell-to-add-users-in-local-group-in-Confluence/qaq-p/1542009
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.