Confluence'da yeni bir sayfa oluşturmak için benzer bir soru buldum, ancak örneğin Google Uygulama Komut Dosyasındaki kimliğe dayalı olarak bir confluence Bulut sayfasının içeriğini almak ve sayfanın gövdesinin içeriğini ayrıştırmak için belirli bir soru bulamadım. Örneğin, bir JSON sonucunu ayrıştırmak veya belki de belirli nesnenin içeriğini almak için Confluence REST-API'sini kullanmak.
Kaynak kodunu belirtilen sorudan aşağıdaki gibi uyarladım:
function myFunction() {
const url = "https://<company>.atlassian.net/wiki/rest/api/content/<ID>";
const token = "<token>";
const user = "<email>";
headers = { "Authorization": "Basic " + Utilities.base64Encode(user + ':' + token) };
var params = {
"method": "GET",
"headers": headers,
"muteHttpExceptions": false,
"contentType": "application/json"
};
let createResponse = UrlFetchApp.fetch(url, params);
console.log(createResponse.getContentText());
}
nerede <xxxx>
bunlar hesabımla ilgili belirli parametrelerdir. <ID>
izdiham belgesi kimliğidir.
İzdiham Bulutu için REST API spesifikasyonunu takip ediyorum
Bir yanıt alıyorum, ancak sayfa hakkında genel özellik sağlıyor.
URL'yi aşağıdakiyle değiştirme:
https://<company>.atlassian.net/wiki/rest/api/content/<ID>?expand=body.storage
aşağıdaki son eki ekleme: ?expand=body.storage
içeriği üretir, ancak ayrıştırılması zordur:
{"id":"2020706439","type":"page","status":"current","title":"Onboard Resource Template for
more than one resource","macroRenderedOutput":{},"body":{"storage":{"value":"<ac:structured-macro ac:name=
\"info\" ac:schema-version=\"1\" ac:macro-id=\"756d4d54-7492-49ac-b502-19d1a740ea92\"><ac:rich-text-body><p>
To use it, please make a copy of this template and replace the title with Resource Name(s) and add the
onboarding date as a suffix</p></ac:rich-text-body></ac:structured-macro><table data-layout=\"wide\">
<colgroup><col style=\"width: 182.0px;\" /><col style=\"width: 144.0px;\" /><col style=\"width: 148.0px;\" />
<col style=\"width: 143.0px;\" /><col style=\"width: 137.0px;\" /><col style=\"width: 142.0px;\" />
</colgroup><tbody><tr><td data-highlight-colour=\"#6fa8dc\" colspan=\"6\"><p style=\"text-align: center;\">
<strong>New Resource (s) Onboarding Information and Tracking</strong></p></td></tr>
<tr><td data-highlight-colour=\"#ff9900\"><p>Information Provided by Vendor</p></td>
<td data-highlight-colour=\"#ff9900\"><p>Resource 1</p></td><td data-highlight-colour=\"#ff9900\">
<p>Resource 2</p></td><td data-highlight-colour=\"#ff9900\"><p>Resource 3</p></td><td data-highlight-colour=\"#ff9900\">
<p>Resource 4</p></td><td data-highlight-colour=\"#ff9900\"><p>Resource 5</p></td></tr><tr><td><p>First
Name</p></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Last
Name</p></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Address</p></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Phone Number</p></td><td>
<p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>E-Mail</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>WFH or W@Office</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Location (if W@Office)</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Role</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td><p>Start Date</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td><p>End Date</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td><p>Vendor's Name</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td><p>Vendor's Contact Name</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Vendor's Phone Number</p></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Manager's Name</p></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Team</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td data-highlight-colour=\"#b6d7a8\" colspan=\"6\">
<p>Information Provided by Onboarding Manager</p></td></tr><tr><td><p>New Resource ID</p></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>New
Resource Company E-mail</p></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td></tr><tr><td><p>Cost Center</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td><p>Laptop Serial Number</p></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td data-highlight-colour=\"#b6d7a8\">
<p><ac:inline-comment-marker ac:ref=\"377a17e3-a869-451f-a58b-19cac76916a4\">Access Requests by
Rosana</ac:inline-comment-marker></p></td><td data-highlight-colour=\"#b6d7a8\"><p style=\"text-align: center;\">
Ticket Number</p></td><td data-highlight-colour=\"#b6d7a8\"><p style=\"text-align: center;\">Date </p><p style=\"text-align: center;\">
Submitted</p></td><td data-highlight-colour=\"#b6d7a8\"><p>SNOW Assignee</p></td>
<td data-highlight-colour=\"#b6d7a8\"><p style=\"text-align: center;\">
Ready in<ac:inline-comment-marker ac:ref=\"269ae226-6036-4ede-9720-d3c25f5d31d2\"> </ac:inline-comment-marker>(n)-Days</p></td>
<td data-highlight-colour=\"#b6d7a8\"><p style=\"text-align: center;\">Date Completed</p></td></tr><tr><td><p>Company ID Request</p></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Laptop</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td><p>Slack</p></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td>
<p>Outlook</p></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>WebEx</p></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>Ping</p></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td></tr><tr><td data-highlight-colour=\"#a2c4c9\" colspan=\"6\"><p>Access Request by
Program Manager (or a PM on his behalf)</p></td></tr><tr><td><p>SNOW Access and Timesheets</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td data-highlight-colour=\"#f4cccc\" colspan=\"6\">
<p>Access Request/Action by David Leal</p></td></tr><tr><td><p>Access to Jira/Confluence</p></td>
<td><p /></td><td><p /></td><td><p>Jira Admin</p></td><td><p /></td><td><p /></td></tr>
<tr><td><p>Resource Plan</p></td><td><p /></td><td><p /></td><td><p>Snow Manager</p></td>
<td><p /></td><td><p /></td></tr>
<tr><td><p><em>Actions</em></p></td><td data-highlight-colour=\"#f4f5f7\" colspan=\"5\"><p style=\"text-align: center;\">
<em> Date Completed</em></p></td></tr><tr><td><p style=\"text-align: right;\">Add to Slack Channels</p></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr>
<td><p style=\"text-align: right;\">Add to JIRA Projects</p></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr>
<tr><td data-highlight-colour=\"#fff2cc\"><p>Access Requests by Tech Lead</p></td>
<td data-highlight-colour=\"#fff2cc\"><p>Ticket Number</p></td><td data-highlight-colour=\"#fff2cc\"><p>Date Submitted</p></td>
<td data-highlight-colour=\"#fff2cc\"><p>SNOW Assginee</p></td><td data-highlight-colour=\"#fff2cc\"><p>Ready in Days</p></td>
<td data-highlight-colour=\"#fff2cc\"><p>Date Completed</p></td></tr><tr><td><p>AWS Work Space (VDI)</p></td>
<td><p /></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>GitLab</p></td><td><p /></td><td><p /></td>
<td><p /></td><td><p /></td><td><p /></td></tr><tr><td><p>AWS Console</p></td><td><p /></td><td><p /></td><td><p /></td><td><p /></td>
<td><p /></td></tr></tbody></table><p />",
"representation":"storage","embeddedContent":[],"_expandable":{"content":"/rest/api/content/2020706439"}},
"_expandable":{"editor":"","atlas_doc_format":"","view":"","export_view":"","styled_view":"","dynamic":"",
"editor2":"","anonymous_export_view":""}},"extensions":{"position":158},"_expandable":{"childTypes":"","container":
"/rest/api/space/PDC","metadata":"","operations":"","schedulePublishDate":"","children":"/rest/api/content/2020706439/child",
"restrictions":"/rest/api/content/2020706439/restriction/byOperation","history":"/rest/api/content/2020706439/history",
"ancestors":"","version":"","descendants":"/rest/api/content/2020706439/descendant","space":
"/rest/api/space/PDC"},"_links":{"editui":"/pages/resumedraft.action?draftId=2020706439","webui":
"/spaces/PDC/pages/2020706439/Onboard+Resource+Template+for+more+than+one+resource","context":"/wiki",
"self":"https://<company>.atlassian.net/wiki/rest/api/content/2020706439","tinyui":"/x/h4hxe","collection":
"/rest/api/content","base":"https://pan-american.atlassian.net/wiki"}}
almak istediğim içerik, bunun gibi bir birleşme tablosunun bir parçası:
İşte bu sorunla ilgili şu soru:
- Bu, ayrıştırmak için İzdiham sayfası içeriğini almak için en iyi yaklaşım mı? örneğin, seçeneği kullanma:
expand=body.storage
ya da tam tersine, İzdiham sayfasının (veya belirli bir tablonun) içeriğini elde etmenin daha iyi yolları vardır, bu nedenle ayrıştırılması daha kolaydır. - Elde edilen içerik bunu yapmanın en iyi yoluysa, tablo içeriğini ayrıştırmak için herhangi bir HTML tablosu javascript kütüphanesi veya aracı veya komut dosyası var mı?
expand=body.storage