0

Below is my code for the IBM Watson document conversion. I keep on getting the error message below when I try to run script in Python. I have my username and password XXXX'd out in the code below, but I have copied and pasted my active username and password so I do not know what would be causing the credential issue. Any help would be appreciated.

watson_developer_cloud.watson_developer_cloud_service.WatsonException: Unauthorized: Access is denied due to invalid credentials

import json
from os.path import join, dirname
from watson_developer_cloud import DocumentConversionV1

document_conversion = DocumentConversionV1(
    username="XXXXXXXXXXX",
    password="XXXXXXXXXXXXXXXXX",
    version='2015-12-15')

with open(join(dirname(__file__), 'a16-23019_2nq.htm'),
      'r') as document:
    config = {'conversion_target':DocumentConversionV1.NORMALIZED_HTML}
    print(document_conversion.convert_document(
        document=document, config=config, media_type='text/html').content)
Foon
  • 6,148
  • 11
  • 40
  • 42

2 Answers2

1

Drew, I do not know if you're using your Bluemix credentials, but if it is, it will not work because in the case IBM Request the Service Credentials.

In case you should get the credentials of the service inside the "Document Conversion" as shown in the attached image below. If you are putting the credentials and it still is not working, try code 2.

Example:

document_conversion = DocumentConversionV1(
    username='67bxxx-xxxxx-xxxxxx-xxxxx-xxx',
    password='fWxxxxxxxxxxxxx',
    version='2016-02-09')

or Try it with JSON format:

document_conversion = DocumentConversionV1(
  username='{username}',
  password='{password}',
  version='2015-12-15'
)

Step 1, click on the link:

enter image description here

Step 2, Get credentials and enter in your code:

enter image description here

If you have more questions, you can see this example and this link with the examples from Watson Document Service (Python) and I'll try answer to help you too.

Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53
0

Make sure that you have the userid and password the right way round. This is a common mistake, the way you can tell is that the userid will be long and the password will be short.

chughts
  • 4,210
  • 2
  • 14
  • 27