pythonibm-cloudibm-watsonwatsondocument-conversion

Partial response of documentconversionV1()


I am trying to use DocumentConversionV1 function of watson_developer_cloud API on python , However the response in my case comes only as "<"Response 200">".

import sys
import os as o
import json
import codecs
from watson_developer_cloud import DocumentConversionV1

document_conversion = DocumentConversionV1(
  username="873512ac-dcf7-4365-a01d-7dec438d5720",
  password="bvhXbdaHtYgw",
  version='2016-02-10',
  url= "https://gateway.watsonplatform.net/document-conversion/api",

)
config = {
  'conversion_target': 'NORMALIZED_TEXT',  
}
i = "v.docx"
with open((i),'rb') as doc:
    res = document_conversion.convert_document(document = doc , config = config)
    print(res)

Solution

  • First and foremost, delete your service credentials and recreate them through Bluemix. (Posting them on a public forum is usually a bad idea.) ;o)

    Now, to actually answer the question... You want to get the content of the response. Right now, you're printing the response itself. Try

    print(res.content)
    

    See https://github.com/watson-developer-cloud/python-sdk/blob/master/examples/document_conversion_v1.py#L16