Confluence Scriptrunner Macro API: Upload an attachment (JQuery) Example.
Please can someone advise me if it is possible to upload an attachment via an API using JQuery within a Confluence SR Macro?
I have successfully created a new page using the following example:
var jsondata = {"type":"page",
"title":"My Test Page1",
"space":{"key":"TST"},
"body":{"storage":{"value":"<p>This is a TEST new page</p>","representation":"storage"}}};
AJS.$.ajax({
url: "https://confluence_server:8100/confluence/rest/api/content/",
type: "POST",
data:JSON.stringify(jsondata),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(msg){
console.log("Success !");
}
});
The Atlassian Documentation:
Confluence REST API examples (atlassian.com)
Gives a curl example:
curl -v -S -u admin:admin -X POST -H "X-Atlassian-Token: no-check" -F "file=@myfile.txt" -F "comment=this is my file" "http://localhost:8080/confluence/rest/api/content/3604482/child/attachment" | python -mjson.tool
Please can you also advise what upload file paths are allowed for Windows Edge Chromium Browser i.e:
1) file : "//confluenec_server/temp/test.txt"
2) file : "file://localserver/temp/test.txt"