Postman example to convert DOCX to HTML without storage using Aspose.Words Cloud API

I am evaluating this product and hoping to produce a proof of concept. I want to be able to send a base 64 encoded document in the request and receive the doc converted to html back as a stream in the response - is this possible with Aspose? If so, do you have a sample postman example you could export for me?

@Heather486

Thank you for contacting Aspose Support.

Please check this .NET example of converting Word Document to HTML TestPutConvertDocument. Simply replace var format = "pdf"; with var format = "html";

and cURL example would be:

curl -v "https://api.aspose.cloud/v1.1/words/convert?format=html&appSID=0B17F60A-6D69-426B-9ABD-79F35A6E9F7B&signature=a4iW%2FZrB6iSVZaIEjXAi94zkzQc" \
     -X PUT \
     -T Rendering.docx \
     -H "Content-Type: multipart/form-data" \
     -H "Accept: multipart/form-data" \
     -o Rendering.html

Please check Aspose.Words API Reference guide to get information about all REST APIs.

Hi sohail, I am still confused about what the fully formed request looks like when it is actually sent/received. I do not want to run .Net or Java code underneath, I want to be able to make a pure REST call - I would like to see a fully formed sample request and sample response, which I cannot find on your site. Is this something that can be done?

@Heather486

Sure. Let me share with you Postman example.

@sohail.aspose - that would be perfect. Are you going to post it here?

@Heather486

Yes, this Postman example and all our conversation would be here.

Hi @sohail.aspose - have you already posted or attached it. I don’t see it yet.

@Heather486

Please check Postman example here Word to PDF Conversion

Following steps may help you in understanding this Postman example:

  1. Get your App Key and App SID from https://dashboard.aspose.cloud/
  2. Get your Access Token by calling https://api.aspose.cloud/oauth2/token API (as shown in Postman Example). We use OAuth 2.0 to authenticate Aspose for Cloud REST APIs. Please check this article for more details: Authenticating API Requests|Documentation
  3. Call https://api.aspose.cloud/v1.1/words/convert API, it would convert Rendering.docx file to Rendering.html. outPath parameter is optional; if this parameter is missing the API will return converted document as API response

For more clarity I have also written cURL example for Word to HTML conversion:

curl -v 'https://api.aspose.cloud/v1.1/words/convert?format=html' \
-X PUT \
-T Rendering.docx \
-H 'Accept: multipart/form-data' \
-H 'Authorization: Bearer 4yTby6mXrMX52g4LCNW1p3PSmiltKT4ZASTvYePGHcz-9EmhKKiu98FtnnWQSjX3SxNcyS6v8dvmss9xGwVp5GQ6vNhqimcYSqTploU4ttAxF6fJafJZK4ekck9Qf40Xgcpndi8hEyoIzZMBEZ5NsncGtbWMDlNCBgzNADNZ-9yVOyfmhIMR3vgqmhpc8X_VCmET1Azku3IL_x1vympIM3XyBBzRWdRCa8XeQ1GjKCDIx3oHThxRLCykCf6XlYyEPPu7MPaQR-qeO-wVdp5ASKZf6dHlbNIn-ia6K40u44LyPHvVauU8MMgWX-NvF_XYezg-Oo7rLG6F-ue5MY9C_d2PrA8_AI-ig6NOkGyOoc5tyiwcsidldIJocLHnXZCjrUhTSHW8ZoSnwvQuGHb-uDFa0ohbukE97zS-FRgAhHLqnrWp' \
-H 'Content-Type: multipart/form-data' \
-o Rendering.html

@sohail.aspose - these worked great and they made the structure of the requests much clearer for me. Thank you so much.

I have one last issue - I attempted to leave out the outPath and received various errors, including “Illegal characters in path.” and a message saying version 1.1 doesn’t support my request. How must I structure the request to receive my html directly back without the get request? Thanks again for your excellent assistance.

@Heather486

Thanks for your kind words.

The issue is not with the API as you can confirm with the given cURL example or with the SDKs examples (that are directly saving API response as HTML file).

The issue is with our Postman example and I am trying to fix it.

Hi @sohail, were you able to get this working? Thanks so much.

@Heather486

We have logged the issue in our internal tracking software (WORDSCLOUD-371) and working to fix it. I will update you here as soon as the issue is fixed.

@Heather486

I have updated the Postman example. Now you should be able to get converted document directly in API response:

Postman was adding quotes around the filename in multipart headers for “form-data” requests. To fix it I used binary body instead of form-data https://i.imgur.com/6AC4ms5.jpg

In Aspose.Words for Cloud next release, the Postman example would work without this workaround.

Please let us know if you have any questions.

@Heather486

Kindly note recently, we have release API Version V4.0 of Aspose.Words Cloud. It has better memory management and an optimized API structure.

This release uses JSON Web Token(JWT) for request authentication along with other changes. Please check the sample cURL example for API Version V4.0. Please feel free to contact us for any further assistance in this regard.

// First get Access Token
// Get Client Secret and Client Id from https://dashboard.aspose.cloud/
curl -X POST "https://api.aspose.cloud/connect/token" 
-d "grant_type=client_credentials&client_id=xxxxx-xxxx-xxxx-xxxx-xxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxx" 
-H "Content-Type: application/x-www-form-urlencoded" 
-H "Accept: application/json"

# cURL example to convert MS Word Document to HTML
curl -v "https://api.aspose.cloud/v4.0/words/convert?format=html" 
-X PUT 
-F document=@TableDocument.doc 
-H "Content-Type: multipart/form-data" 
-H "Accept: multipart/form-data" 
-H "Authorization: Bearer <jwt token>" 
-o TableDocument.html