Free Support Forum - aspose.cloud

C# WordsApi.PostAppendDocument not compiling

Hello. I’m attempting to append multiple .docx files together. I followed the example here.

https://docs.aspose.cloud/display/wordscloud/Append+a+List+of+Word+Documents

Yet I’m getting the compiler error: “WordsApi does not contain a definition for PostAppendDocument”

I’m stuck and cannot move forward. Please help. Below is the example I followed.

`/*`

`    * Working with Document`

`    * Append a List of Word Documents`

`    *`

`    */`

`    WordsApi wordsApi = ` `new` `WordsApi(` `"xxxx"` `, ` `"xxx"` `, ` `"http://api.aspose.com/v1.1"` `);`

`    StorageApi storageApi = ` `new` `StorageApi(` `"xxxx"` `, ` `"xxx"` `, ` `"http://api.aspose.com/v1.1"` `);`

 

`    ` `//set destination file name`

`    String destFileName = ` `"test_doc.docx"` `;`

 

`    ` `//set source file name`

`    String sourceFileName = ` `"test_uploadfile.docx"` `;`

 

`    Com.Aspose.Words.Model.DocumentEntryList body = ` `new` `Com.Aspose.Words.Model.DocumentEntryList();`

`    List<Com.Aspose.Words.Model.DocumentEntry> docEntries = ` `new` `List<Com.Aspose.Words.Model.DocumentEntry>();`

 

`    Com.Aspose.Words.Model.DocumentEntry docEntry = ` `new` `Com.Aspose.Words.Model.DocumentEntry();`

`    docEntry.Href = sourceFileName;`

`    docEntry.ImportFormatMode = ` `"KeepSourceFormatting"` `;`

 

`    docEntries.Add(docEntry);`

`    body.DocumentEntries = docEntries;`

`    ` `try`

`    {`

`//upload source file to aspose cloud storage`

`storageApi.PutCreate(sourceFileName, ` `""` `, ` `""` `, System.IO.File.ReadAllBytes(` `"\\temp\\resources\\"` `+ destFileName));`

 

`//upload destination file to aspose cloud storage`

`storageApi.PutCreate(destFileName, ` `""` `, ` `""` `, System.IO.File.ReadAllBytes(` `"\\temp\\resources\\"` `+ sourceFileName));`

 

`//invoke Aspose.Words Cloud SDK API to append word document`

`Com.Aspose.Words.Model.DocumentResponse apiResponse = wordsApi.PostAppendDocument(destFileName, ` `null` `, ` `null` `, ` `null` `, body);`

 

`if` `(apiResponse!=` `null` `&& apiResponse.Status.Equals(` `"OK"` `)){`

`    Console.WriteLine(` `"Documents have been appended successfully"` `);`

`    ` `//download appended document from storage server`

`    Com.Aspose.Storage.Model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, ` `null` `, ` `null` `);`

`    System.Diagnostics.Debug.WriteLine(` `"response:"` `+ storageRes.ResponseStream);`

`    System.IO.File.WriteAllBytes(` `"\\temp\\"` `+ sourceFileName, storageRes.ResponseStream);`

`}`

`    }`

`    ` `catch` `(Exception ex)`

`    {`

`System.Diagnostics.Debug.WriteLine(` `"error:"` `+ex.Message+` `"\n"` `+ex.StackTrace);`

`    }`

@titani

We are sorry for the inconvenience. Recently we have released V4 API Version of Aspose.Words Cloud and we are in the process of updating the documentation. Please check updated code for appending documents as follows. You may also check complete unit tests of Aspose.Words Cloud SDK for .NET from GitHub repository.

WordsApi wordsApi = new WordsApi(MyAppKey, MyAppSid);

var fileName = "02_pages.docx";
var documentToAppend = "02_pages_copy.docx";
var localFolder = "C:/Temp/";
string remoteFolder = null;
string destFileName = null;
            
var body = new DocumentEntryList();
System.Collections.Generic.List<DocumentEntry> docEntries = new System.Collections.Generic.List<DocumentEntry>();

DocumentEntry docEntry = new DocumentEntry { Href = documentToAppend, ImportFormatMode = "KeepSourceFormatting" };
docEntries.Add(docEntry);
body.DocumentEntries = docEntries;

UploadFileRequest uploadRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(System.IO.File.OpenRead(localFolder+fileName), fileName);
wordsApi.UploadFile(uploadRequest);
uploadRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(System.IO.File.OpenRead(localFolder + documentToAppend), documentToAppend);
wordsApi.UploadFile(uploadRequest);

var request = new AppendDocumentRequest(fileName, body, remoteFolder, destFileName: destFileName);
var actual = wordsApi.AppendDocument(request);