简体   繁体   中英

Watson Discovery service create_collection() api call returns Error 415: Unsupported Media Type

I'm using the DiscoveryV1 python library to try to create a new collection in my WDS environment. I have the following code:

from watson_developer_cloud import DiscoveryV1

discovery = DiscoveryV1(
username = "username goes here",
password = "password goes here",
version = "version goes here")

conf_id ='valid configuration_id'
env_id = 'valid environment_id'
new_col = discovery.create_collection(env_id, 'TestV2', configuration_id=conf_id)

The final line of the above block throws the following error: watson_developer_cloud.watson_developer_cloud_service.WatsonException: Error: Unsupported Media Type, Code: 415

Full stack trace:

Traceback (most recent call last):
  File "uploadCorpus.py", line 23, in <module>
    new_col = discovery.create_collection(env_id, 'TestV2', configuration_id=conf_id)
  File "/home/Vito.Colano/Apps/anaconda2/lib/python2.7/site-packages/watson_developer_cloud/discovery_v1.py", line 227, in create_collection
    accept_json=True)
  File "/home/Vito.Colano/Apps/anaconda2/lib/python2.7/site-packages/watson_developer_cloud/watson_developer_cloud_service.py", line 324, in request
    raise WatsonException(error_message)
watson_developer_cloud.watson_developer_cloud_service.WatsonException: 
Error: Unsupported Media Type, Code: 41

This appears to be a bug in the Python SDK for Discovery. I, just now, opened a pull request to fix it. https://github.com/watson-developer-cloud/python-sdk/pull/223

I forgot to say Thank you for asking this question. I only went looking for this bug and figured out what to fix because of your question.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM