Free Support Forum - aspose.cloud

DOCX to PDF conversion in GO using Aspose.Words Cloud API returns 401

I implemented a docx to pdf conversion using the Golang API as followed:
50 file, err := os.Open(origPath)
51 if err != nil {
52 return nil, err
53 }
54 if _, err := file.Seek(0, 0); err != nil {
55 return nil, err
56 }
57
58
59 // save converted pdf
60 resp, err := pr.client.WordsApi.ConvertDocument(pr.ctx, file, “pdf”, nil)
61 defer resp.Body.Close()
62 if err != nil {
63 return nil, err
64 }

I’ve also set up the client as followed and update the config.json file with the sid key and app key generated from https://dashboard.aspose.cloud:
28 // parse config file
29 config, err := models.NewConfiguration(“config.json”)
30 if err != nil {
31 return nil, err
32 }
33 // create API client
34 client, err := api.NewAPIClient(config)
35 if err != nil {
36 return nil, err
37 }

ConvertDocument() returns an “EOF” error. When I instrumented the ConvertDocument() function, it got a 401 status from client.callAPI() [https://github.com/aspose-words-cloud/aspose-words-cloud-go/blob/master/api/words_api.go#L648]

Could you help me figure out what the issue is? Do I need to provide additional info for authentication?

@tnhuynh

We are sorry for your inconvenience. We are looking into the issue and will update you shortly.

@tnhuynh

Thanks for your patience. I have tested DOCX to PDF Conversion and unable to notice the issue. However, If I provide incorrect APP KEY and SID then I get EOF error. Please double check that you have set your correct APP KEY and SID in config.json.

sample with dummy values:

{
“AppKey”: “1cfb0bbe1f123456583a1cbb3396d42b”,
“AppSid”: “F9DC37CC-7E05-4444-9191-14899DF5012”,
“BaseUrl”: “https://api.aspose.cloud
}

Hi @tilal.ahmad,

Thank you for helping me look into the issue! I copied the APP KEY and SID directly from https://dashboard.aspose.cloud/#/app/105503. I also printed it out after creating the config to double check as followed:
// parse config file
config, err := models.NewConfiguration(“config.json”)
fmt.Println(“Aspose configs:”)
fmt.Println("-BaseURL:", config.BaseUrl)
fmt.Println("-AppKey:", config.AppKey)
fmt.Println("-AppSid:", config.AppSid)

And the printed data match the data on the cloud dashboard. I can email you that info if you’d like?

@tnhuynh

Thanks for your feedback. Please share your APP Key and SID via private message. I will test the scenario with your credentials and will guide you accordingly.