atlassian 分为两种
- cloud
- data center 、server
这个 js 库可以同时支持这两种服务。
cloud - ConfluenceClient
server - ServerClient
- Personal Access Tokens
- Welcome to Atlassian Python API’s documentation! — Atlassian Python API 4.0.4 documentation
jira = Jira(
url='https://your-jira-instance.company.com',
token=jira_access_token
)
confluence = Confluence(
url='https://your-confluence-instance.company.com',
token=confluence_access_token
)
const client = new ServerClient({
host: 'https://kms.fineres.com',
authentication: {
oauth2: {
accessToken: '',
}
},
apiPrefix: '/',
});
cloud 和 dc/server 的区别是
Atlassian Document Format 这个 adf 文档格式,只在 cloud 上支持。
因此 Introduction - Markdown Confluence Tools 这个工具, 即无法使用。
- 所以, obsidian 的插件, confluence intergration 也无法使用。
因此,当我在 server 中,尝试上传附件,并在文档中调用 rest api 去使用附件时,发现无法上传。
ServerClient 中的描述如下。
/**
* The body of the new content. Does not apply to attachments. Only one body format should be specified as the * property for this object, e.g. `storage`. * * Note, `editor2` format is used by Atlassian only. `anonymous_export_view` is the same as 'export_view' format but * only content viewable by an anonymous user is included.
*/
body?: {
view?: ContentBodyCreate;
export_view?: ContentBodyCreate;
styled_view?: ContentBodyCreate;
storage?: ContentBodyCreate;
editor2?: ContentBodyCreate;
anonymous_export_view?: ContentBodyCreate;
atlas_doc_format?: ContentBodyCreate;
};
可以尝试使用
中的资源格式来进行上传附件。
经过我对 confluence server 的分析, 需要
先上传到 confluence 页面中
然后才能在页面中使用,因此结合资源格式就很明白了。
先调用附件上传功能, 然后使用资源格式,将附件插入文档中, 然后修改文档内容。 见 https://github.com/3dot141/confluence-server-sync
效果见 https://kms.fineres.com/pages/viewpage.action?pageId=1321890178
注意
通过 getContentById 获取 body 中的信息时
需要
const content = await client.content.getContentById({
id: "1321882969",
expand: [GetContentById.Expand.Body, "body.storage", GetContentById.Expand.AllChildTypes, GetContentById.Expand.Version]
})
expand 中输入 body.storage
。同理如果是内部的值,需要通过这种方式去钻取。