IBM Watson API Test

I have been meaning to post something like this code for a while. Here is an example of calling one of the IBM watson API’s from a MRS script.  Its just code and i think easy to understand. The full API i am playing with can be found here.

Dim sUrl
Dim http
Dim apiHash

sUrl = ""
set oHTTP = createObject("Microsoft.XMLHTTP")"GET", sUrl, false)
'The string after "Basic" is the base64 encoded of apikey:[YourAPIKEY]
'I.e.: apihash = Base64Encode("apikey:[YourAPIKEY]")

apiHash = "[YOURHASH]"
oHTTP.setRequestHeader("Authorization", "Basic " + apiHash)
oHTTP.setRequestHeader("content-type", "application/json")

If oHTTP.status = 200 Then
    debug.Log("RESPONSE : " + oHTTP.responseText)
    debug.Log("ERRCODE : " + ctext(oHTTP.status))
    debug.Log("RESPONSE : " + oHTTP.responseText)
End If

Leave a Comment

%d bloggers like this: