How to convert RTF to PDF in .NET?

HI,

I cannot convert a document from rtf to pdf.

My code

    public async Task<byte[]> ConvertArticle(string fileName, string destinationFormat) {

        var appKey = Configuration["ASPOSE_APP_KEY"];
        var appSid = Configuration["ASPOSE_APP_SID"];

        var wordsApi = new WordsApi(appKey, appSid);

        var request = new ConvertDocumentRequest(File.OpenRead(fileName), destinationFormat);
        var result = wordsApi.ConvertDocument(request);

        await using MemoryStream ms = new MemoryStream();
        await result.CopyToAsync(ms).ConfigureAwait(false);

        return ms.ToArray();

    }

The error:

Aspose.Words.Cloud.Sdk.ApiException: Bad Request
at Aspose.Words.Cloud.Sdk.RequestHandlers.ApiExceptionRequestHandler.ThrowApiException(HttpResponseMessage response)
at Aspose.Words.Cloud.Sdk.RequestHandlers.ApiExceptionRequestHandler.ProcessResponse(HttpResponseMessage response)
at Aspose.Words.Cloud.Sdk.ApiInvoker.<>c__DisplayClass14_0.b__1(IRequestHandler p)
at System.Collections.Generic.List1.ForEach(Action1 action)
at Aspose.Words.Cloud.Sdk.ApiInvoker.InvokeApiInternal(HttpRequestMessage httpRequest)
at Aspose.Words.Cloud.Sdk.ApiInvoker.InvokeApi(Func1 httpRequestFactory) at Aspose.Words.Cloud.Sdk.RequestHandlers.OAuthRequestHandler.RequestToken() at Aspose.Words.Cloud.Sdk.RequestHandlers.OAuthRequestHandler.ProcessRequest(HttpRequestMessage request) at Aspose.Words.Cloud.Sdk.ApiInvoker.<>c__DisplayClass14_0.<InvokeApiInternal>b__0(IRequestHandler p) at System.Collections.Generic.List1.ForEach(Action1 action) at Aspose.Words.Cloud.Sdk.ApiInvoker.InvokeApiInternal(HttpRequestMessage httpRequest) at Aspose.Words.Cloud.Sdk.ApiInvoker.InvokeApi(Func1 httpRequestFactory)
at Aspose.Words.Cloud.Sdk.WordsApi.ConvertDocument(ConvertDocumentRequest request)
at Article_Format_Conversion_Service.AsposeArticleConvertor.ConvertArticle(String fileName, String destinationFormat) in C:\Users\jiri\source\repos\Article Format Conversion Service\AsposeArticleConvertor.cs:line 26
at Article_Format_Conversion_Service.Controllers.ConversionController.Get(String filename, String languageCode, String format) in C:\Users\jiri\source\repos\Article Format Conversion Service\Controllers\ConversionController.cs:line 47
at lambda_method4(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS

Connection: keep-alive
Accept: /
Accept-Encoding: gzip, deflate, br
Host: localhost:5001
User-Agent: PostmanRuntime/7.28.4
Postman-Token: e3987fa5-18ed-41cb-ad28-c4cade7a07b9

@ProSyn

Please note WordsApi method accepts Client Id and Client Secret values in the following order. Kindly use the latest version of Aspose.Words Cloud SDK for .NET and update your code accordingly, it should resolve the issue.

WordsApi wordsApi = new WordsApi(MyClientId, MyClientSecret);