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)
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:
Step 2, Get credentials and enter in your code:
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.