尝试将curl与api结合使用,给出404错误



我正在尝试使用API查询Confluence知识库页面,但失败。

我已经研究了api,并有以下内容:

浏览内容

curl -u admin:admin http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool

读取内容并展开正文:

curl -u admin:admin http://localhost:8080/confluence/rest/api/content/3965072?expand=body.storage | python -mjson.tool

我实际上想做的是在"空格"中转储一个/多个页面的内容。Confluence将其调用到文件或屏幕上。

这是一个实际的页面:

"https://bob.atlassian.net/wiki/spaces/BKB/pages/1234567/BOB +知识+ BANK"

这是一个我发现使用REST API做我想做的事情的例子:

curl -u admin:admin -G "http://myinstance.address:8090/rest/api/content/search" --data-urlencode "cql=(type=page and space=low and title ~ "LOWERTOWN")"  | python -m json.tool

如何翻译我所研究的内容:

curl -u "bob@bob.com:12345678" -G "https://bob.atlassian.net/rest/api/content/search" --data-urlencode "cql=(type=page and space=BKB and title ~ "BOB+KNOWLEDGE+BANK")"  | python -m json.tool

导致以下错误:

curl: (3) URL using bad/illegal format or missing URL
No JSON object could be decoded

我从这个网站上抓取了我的逻辑:

https://community.atlassian.com/t5/Confluence-questions/How-to-get-Conflunece-knowledge-base-data-through-API/qaq-p/1030159

我想我误解了这个:

/rest/api/content/search

以及它在我的curl语句中的位置,并将其链接到知识库。我也不确定是否应用-mjson。工具是否适用于我的情况,或者如果我实际安装了它/需要验证。

你能帮我正确地解释一下吗?

你就快成功了!您只需要将cql作为查询参数传递给服务,就像Atlassian文档中提到的那样:

curl——request GET
——url 'https://your-domain.atlassian.net/wiki/rest/api/search?cql={cql}'
——header 'Authorization: Bearer'
——header 'Accept: application/json'

最新更新