I'm testing the OpenCalais web service. This is a web service which needs an API key to be used (registering takes only 1 minute in http://www.opencalais.com/APIkey). To check the service first I've used a Python script, taken from [1]
import httplib2 import json LOCAL_API_KEY = '' # Aquire this by registering at the Calais site CALAIS_TAG_API = 'http://api.opencalais.com/tag/rs/enrich' # Some sample text from a news story to pass to Calais for analysis test_body = """ Some huge announcements were made at Apple's Worldwide Developer's Conference Monday, including the new mobile operating system iOS 5, PC software OS X Lion, and the unveiling of the iCloud. """ # header information need by Calais. For more info see http://www.opencalais.com/documentation/calais-web-service-api/api-invocation/rest headers = { 'x-calais-licenseID': LOCAL_API_KEY, 'content-type': 'text/raw', 'accept': 'application/json', } # Create your http object http = httplib2.Http() # Make the http post request, passing the body and headers as needed. response, content = http.request(CALAIS_TAG_API, 'POST', headers=headers, body=test_body) jcontent = json.loads(content) # Parse the json return into a python dict print json.dumps(jcontent, indent=4) # Pretty print the resulting dictionary returned. The Python script works fine for me. I have tried to translate the code above, but my version in Pharo 2.0 using Zinc returns "I Read a ZnResponse(415 Unsupported Media Type text/plain 365B)" | httpClient localApiKey | localApiKey := ''. " my API key " httpClient := ZnClient new logToTranscript; url: 'http://api.opencalais.com/tag/rs/enrich'; method: #POST; headerAt: 'x-calais-licenseID' put: localApiKey; headerAt: 'accept' put: 'application/json'; headerAt: 'content-Type' put: 'text/raw'; contents: 'Some huge announcements were made at Apple''s Worldwide Developer''s Conference Monday, including the new mobile operating system iOS 5, PC software OS X Lion, and the unveiling of the iCloud.'. httpClient execute. Additionally the request returns the following message: 'Document conversion error. Please make sure that the content-type (passed through the paramsXML) matches this document contents. [ErrorMessage: com.clearforest.platform.system.CLFRuntimeException: There is no converter for this type of URI "file:/C:/CLFSW/v71/ct/bin/../../../v71/ct/var/dptemp/prvt/228295-app9/dp/papi/data/1374378595643-DF317E60-6634505.asc" ]' From what I could see, a difference is the 'text/raw' content-type is passed in Python's httplib2, but in Zinc is overriding by 'text/plain' it in #acceptEntityDescription: ? Any hints? Hernán [1] http://www.flagonwiththedragon.com/2011/06/08/dead-simple-python-calls-to-open-calais-api/