Calling External HTTPS RestService using RestClient.NewSecure ?
Hi All,
Has anyone successfully used restClient.NewSecure (preferred) (also tried sockets, but connection closed error there) to successfully call an https service (specifically azure cognitive services), and if so, could you give me a pointer on what is wrong with my code? Attached is a java routine that works perfectly (DetectLanguage) obviously with a valid key for ACS , but if I try and run what I believe to be the equivalent in the code in Oscript below using RestClient, I get an authentication failure. (Missing access token - but all that should need to be provided is the subscription key that works when called from java using DetectLanguage code.
//Create JSON content
Has anyone successfully used restClient.NewSecure (preferred) (also tried sockets, but connection closed error there) to successfully call an https service (specifically azure cognitive services), and if so, could you give me a pointer on what is wrong with my code? Attached is a java routine that works perfectly (DetectLanguage) obviously with a valid key for ACS , but if I try and run what I believe to be the equivalent in the code in Oscript below using RestClient, I get an authentication failure. (Missing access token - but all that should need to be provided is the subscription key that works when called from java using DetectLanguage code.
function CallRestClient()
String hostname = "ottextanalytics.cognitiveservices.azure.com"
Integer port = 443
String baseURI = "https://ottextanalytics.cognitiveservices.azure.com/text/analytics/v2.1/languages"
Integer timeout = 200
Assoc params
List docHeaders={'countryHint','id','text'}
Recarray docArray = RecArray.Create(docHeaders)
Assoc documents
String jsonContent, body
Integer bodyLen = 0
Assoc retVal
//Create connection
//Create connection
RestClient acsClient=RestClient.NewSecure(hostname, port,\
baseURI, timeout)
//Populate parameters
//Populate parameters
params.("Ocp-Apim-Subscription-Key")="xxxxxxxxxxxxxxxxxx"
params.("Content-Type")="text/json"
//Create JSON content
RecArray.AddRecord(docArray,{'US','1','Hello World'})
jsonContent = web.ToJSON(docArray)
documents.documents = jsonContent
body = web.ToJSON(documents)
bodyLen = Length(body)
// Submit request
// Submit request
retVal = acsClient.Post( params, body, bodyLen)
echo(retVal)
end
Most appreciated if anyone can spot where this is going off the rails
Cheers
Iain
Most appreciated if anyone can spot where this is going off the rails
Cheers
Iain
0
Categories
- All Categories
- 107 Developer Announcements
- 53 Articles
- 104 General Questions
- 141 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 898 Cloud Fax and Notifications
- 76 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 118 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management