Automating Scroll using the REST API
Hi
From a .Net application I would like to automate the creation of a word document and save it to a file, with no user intervention, so I’ve been trying to use the Scroll Office Rest API.
To start, I’ve been pasting the URL\permalink & userid & password into a web browsers address bar, but of course I get asked to enter a filename & location before the file is created. Is it possibly to pass the full file name in the permalink so that the document is created automatically with no user intervention?
Regards
Brian
-
After some more investigation it appears that the document is already created in the directory ….\confluence-3.5.13-std\temp\com.k15t.scroll.office on the Confluence server before you are prompted to download the attachment, therefore if I’m using the REST API from a .NET app I only need to read the Response URI to get the file name, I don’t need to send a further response. Once I have the file name there are many ways I can use to rename & copy it to the final destination.
I’ve included my code below in case it my prove of use to someone
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;namespace ConfluenceAPI
{
public class ScrollHTTPGet
{
public string ProduceScrollDoc()
{
string sURL;
sURL = "http://confdev:8080/Confluence/plugins/com.k15t.scroll.office/restExport.action?pageId=6131611&spaceKey=attachmenttest123&settings.templateId=com.k15t.scroll.scroll-office%3Adefaulttemplate&PageSelectionStrategyByCompleteKey=com.k15t.scroll.scroll-office%3Apageonly&com.k15t.scroll.scroll-office%3Afilterbylabel%3AlabelRules=&settings.processTocMacros=TRUE&settings.processChildrenMacros=TRUE&settings.enableHeadingPromotion=TRUE&postprocessors=com.k15t.scroll.scroll-office%3Alinebreaks&postprocessors=com.k15t.scroll.scroll-office%3Athumbnail&postprocessors=com.k15t.scroll.scroll-office%3Apagelabelindexterm";WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);SetBasicAuthHeader(wrGETURL, "confUser", "confPassword");
HttpWebResponse response = (HttpWebResponse)wrGETURL.GetResponse();
string localPath = response.ResponseUri.LocalPath;
//Remove session ID from end of string
string fileName = localPath.Substring(0, response.ResponseUri.LocalPath.LastIndexOf(';'));return fileName;
}private void SetBasicAuthHeader(WebRequest req, String userName, String userPassword)
{
string authInfo = userName + ":" + userPassword;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
req.Headers["Authorization"] = "Basic " + authInfo;
}
}
}
Please sign in to leave a comment.
Comments
1 comment