当前位置: 首页 > 知识库问答 >
问题:

在Confluence Rest API中存储格式作为主体(页面创建)

壤驷彦
2023-03-14

我正在使用PHP开发一个页面导入程序,我遇到了一个使用存储格式创建页面的问题。基本上,我得到了畸形的xhtml错误:

HTTP/1.1 400 Bad Request
Date: Thu, 14 Jan 2016 18:13:48 GMT
Server: Apache-Coyote/1.1
X-ASEN: SEN-6458441
X-Seraph-LoginReason: OK
X-AUSERNAME: XXX
Cache-Control: no-cache, must-revalidate
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-Content-Type-Options: nosniff
Content-Type: application/json
Connection: close
Transfer-Encoding: chunked

{
  "statusCode": 400,
  "data": {
    "authorized": false,
    "valid": true,
    "errors": []
  },
  "message": "Error parsing xhtml"
}
<ac:layout><ac:layout-section ac:type="single"><ac:layout-cell>
<p>Test</p><ac:structured-macro ac:macro-id="3e74101c-857f-4c47-8618-a27c627eea2c" ac:name="info" ac:schema-version="1"><ac:parameter ac:name="title">Fully qualified class name</ac:parameter><ac:rich-text-body>\Zend\Authentication\Adapter\Digest</ac:rich-text-body></ac:structured-macro>
<p><a href="https://github.com/zendframework/zend-authentication/blob/master/src/Adapter/Digest.php">Browse source code</a></p></ac:layout-cell></ac:layout-section><ac:layout-section ac:type="two_left_sidebar"><ac:layout-cell>
<h2>Class contents</h2>
<p><ac:structured-macro ac:macro-id="726aa6fa-6e48-4005-95ad-0fb28aae8162" ac:name="toc" ac:schema-version="1"><ac:parameter ac:name="maxLevel">4</ac:parameter><ac:parameter ac:name="minLevel">3</ac:parameter></ac:structured-macro></p>
<p>&nbsp;</p></ac:layout-cell><ac:layout-cell>
<h2>Description</h2>
<p><ac:structured-macro ac:macro-id="c7feab99-a70b-4ab8-bbac-846ed981bed0" ac:name="excerpt" ac:schema-version="1"><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body>
<p>Digest adapter for Zend Authentication mechanism</p></ac:rich-text-body></ac:structured-macro>&nbsp;</p>
<h2>Class details</h2>
<table style="letter-spacing: 0.1px;">
<tbody>
<tr>
<th>Package</th>
<td>\Zend\Authentication\Adapter</td></tr>
<tr>
<th>Inherited from</th>
<td><span style="color: rgb(68,68,68);">\Zend\Authentication\Adapter\AbstractAdapter</span></td></tr></tbody></table>
<h3>Methods</h3>
<hr /><ac:structured-macro ac:macro-id="43484e81-d0fd-4d40-b990-a7d90cd2b565" ac:name="panel" ac:schema-version="1"><ac:parameter ac:name="borderStyle">solid</ac:parameter><ac:rich-text-body>
<h4>&nbsp;<span style="color: rgb(51,51,51);">::__construct()</span></h4>
<hr />
<p><span style="color: rgb(51,51,51);">&nbsp;</span></p>
<p>Sets adapter options</p><ac:structured-macro ac:macro-id="323db0b7-4961-4b55-8332-43790ef9b2bc" ac:name="code" ac:schema-version="1"><ac:parameter ac:name="language">php</ac:parameter><ac:parameter ac:name="theme">Confluence</ac:parameter><ac:plain-text-body><![CDATA[__construct(mixed $filename = null, mixed $realm = null, mixed $identity = null, mixed $credential = null)]]></ac:plain-text-body></ac:structured-macro>
<h5>Parameters</h5><ac:structured-macro ac:macro-id="eda8fe1a-8ccd-4b7b-8942-99fd9c2dba18" ac:name="expand" ac:schema-version="1"><ac:rich-text-body>
<table>
<tbody>
<tr>
<th>Parameter</th>
<th>Data type</th>
<th>Description</th></tr>
<tr>
<td>$filename</td>
<td>mixed</td>
<td>&nbsp;</td></tr>
<tr>
<td>$realm</td>
<td>mixed</td>
<td>&nbsp;</td></tr></tbody></table></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro></ac:layout-cell></ac:layout-section></ac:layout>
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Post\PostBody;
use GuzzleHttp\Stream\StreamInterface;
use GuzzleHttp\Exception\RequestException;

function send_request() {
    // My API (2) (POST http://confluence.dev/rest/api/content)

    $client = new Client();
    $request = $client->createRequest('POST', 'http://confluence.dev/rest/api/content');
    $postBody = $request->getBody();

    try {
        $request->addHeaders([
            'Authorization'=>'Basic XXX',
            'Content-Type'=>'application/json',
        ]);
        $body = [
            "body" => [
                "storage" => [
                    "value" => "<ac:layout-section ac:type=\"single\"><ac:layout-cell><ac:structured-macro ac:macro-id=\"3e74101c-857f-4c47-8618-a27c627eea2c\" ac:name=\"info\" ac:schema-version=\"1\"><ac:parameter ac:name=\"title\">Fully qualified class name</ac:parameter><ac:rich-text-body>\\Zend\\Authentication\\Adapter\\Digest</ac:rich-text-body></ac:structured-macro>
<p><a href=\"https://github.com/zendframework/zend-authentication/blob/master/src/Adapter/Digest.php\">Browse source code</a></p></ac:layout-cell></ac:layout-section><ac:layout-section ac:type=\"two_left_sidebar\"><ac:layout-cell>
<h2>Class contents</h2>
<p><ac:structured-macro ac:macro-id=\"726aa6fa-6e48-4005-95ad-0fb28aae8162\" ac:name=\"toc\" ac:schema-version=\"1\"><ac:parameter ac:name=\"maxLevel\">4</ac:parameter><ac:parameter ac:name=\"minLevel\">3</ac:parameter></ac:structured-macro></p>
<p>&nbsp;</p></ac:layout-cell><ac:layout-cell>
<h2>Description</h2>
<p><ac:structured-macro ac:macro-id=\"c7feab99-a70b-4ab8-bbac-846ed981bed0\" ac:name=\"excerpt\" ac:schema-version=\"1\"><ac:parameter ac:name=\"atlassian-macro-output-type\">INLINE</ac:parameter><ac:rich-text-body>
<p>Digest adapter for Zend Authentication mechanism</p></ac:rich-text-body></ac:structured-macro>&nbsp;</p>
<h2>Class details</h2>
<table style=\"letter-spacing: 0.1px;\">
<tbody>
<tr>&& count($stdBody) == 0
<th>Package</th>
<td>\\Zend\\Authentication\\Adapter</td></tr>
<tr>
<th>Inherited from</th>
<td><span style=\"color: rgb(68,68,68);\">\\Zend\\Authentication\\Adapter\\AbstractAdapter</span></td></tr></tbody></table>
<h3>Methods</h3>
<hr /><ac:structured-macro ac:macro-id=\"43484e81-d0fd-4d40-b990-a7d90cd2b565\" ac:name=\"panel\" ac:schema-version=\"1\"><ac:parameter ac:name=\"borderStyle\">solid</ac:parameter><ac:rich-text-body>
<h4>&nbsp;<span style=\"color: rgb(51,51,51);\">::__construct()</span></h4>
<hr />
<p><span style=\"color: rgb(51,51,51);\">&nbsp;</span></p>
<p>Sets adapter options</p><ac:structured-macro ac:macro-id=\"9de243a9-ca88-45e1-a6d4-7ff9b542babd\" ac:name=\"code\" ac:schema-version=\"1\"><ac:parameter ac:name=\"language\">php</ac:parameter><ac:parameter ac:name=\"theme\">Confluence</ac:parameter><ac:plain-text-body><![CDATA[__construct(mixed $filename = null, mixed $realm = null, mixed $identity = null, mixed $credential = null)]]></ac:plain-text-body></ac:structured-macro>
<h5>Parameters</h5><ac:structured-macro ac:macro-id=\"a2230db4-ea43-4e99-89d9-2661a57fd5c3\" ac:name=\"expand\" ac:schema-version=\"1\"><ac:rich-text-body>
<table>
<tbody>
<tr>
<th>Parameter</th>
<th>Data type</th>
<th>Description</th></tr>
<tr>
<td>$filename</td>
<td>mixed</td>
<td>&nbsp;</td></tr>
<tr>
<td>$realm</td>
<td>mixed</td>
<td>&nbsp;</td></tr></tbody></table></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro></ac:layout-cell></ac:layout-section>",
                    "representation" => "storage"
                ]
            ],
            "title" => "Adam tests",
            "space" => [
                "key" => "TEST"
            ],
            "type" => "page"
        ];
        $request->setBody(GuzzleHttp\Stream\Stream::factory(json_encode($body)));

        $response = $client->send($request);
        echo "Response HTTP : " . $response->getStatusCode();
    }
    catch (RequestException $e) {
        echo "HTTP Request failed\n";
        echo $e->getRequest();
        if ($e->hasResponse()) {
            echo $e->getResponse();
        }
    }
}

共有1个答案

干茂才
2023-03-14

您可以尝试为存储格式创建如下URL:

http://localhost:8099/rest/api/content/ ?expand=body.storage,version

 类似资料:
  • 问题内容: 我想在Elasticsearch中添加一个日期时间字符串时遇到问题。 该文件如下: 该文档提出了一个错误 我知道我可以在Elasticsearch中使用日期格式,但是即使阅读网站上的文档,我也不知道如何使用。 和 错了。 如何在Elasticsearch中将datetime字符串转换为日期格式? 如何将datetime字符串直接存储到Elasticsearch中? 问题答案: 你快到了

  • 从 Photoshop CC 2015 版开始,“文件”>“存储为 Web 所用格式”选项已被移到“文件”>“导出”>“存储为 Web 所用格式(旧版)”,并且与最新的导出选项放在一起。 要了解这些最新的导出选项,请参阅导出画板、图层以及更多内容。 您可以轻松地将 Photoshop 图像文件存储为各种常见的图像格式。 以 TIFF 格式存储 TIFF 是一种灵活的栅格(位图)图像格式,几乎所有的

  • null null 我没有任何可以作为主键字段。 这里的“eme_request”和“eme_attachment”是主表。 我想知道如何插入表格? 这些表(eme_request、eme_gf_relevent、eme_non_gf_relevent、eme_attachment)将在一个表单请求中插入。 所以我不了解如何在主表中生成主键以及如何将主键作为外键插入子表?

  • 7.9. 储存页面 函数saveHandler处理表单提交。 func saveHandler(w http.ResponseWriter, r *http.Request) { title := r.URL.Path[lenPath:] body := r.FormValue("body") p := &page{title: title, body: [

  • 我已经尝试了所有的解决方案,我可以在互联网上找到,以能够打印一个页面,在Selenium中打开,在Python中。然而,当打印弹出窗口出现时,一两秒钟后它就消失了,没有保存PDF。 2019-07-11更新: 我的问题被认为是重复的,但是a)另一个问题似乎是使用javascript代码,b)答案没有解决这个问题中提出的问题--可能与最近的软件版本有关。使用的Chrome版本是version 75.

  • 我试图创建一个简单的网站,其中托管主题和评论。我已经从主题开始,并为它们创建了存储库: 我已经在servlet上下文中定义了存储库的路径。xml: 现在,我想在我的存储库中包含注释,但以下代码不起作用: 我的项目甚至都没建好。你能给我一个建议吗,如何为多个实体创建存储库(主题类和注释类是用@Entity声明的)? 我面对的是: TopicRepository类图标上有HDD图片 org.sprin