suchowan / watson-api-client

An IBM Watson™ API client
MIT License
27 stars 10 forks source link

Fixes gem based on new IBM URLs. #2

Closed jesseproudman closed 8 years ago

jesseproudman commented 8 years ago

Fixes the URL issues registered in #1.

suchowan commented 8 years ago

Thank you your contribution.

The patch for the method 'rest_access_without_body' did not work well.

c:/Ruby/lib/ruby/gems/2.2.0/gems/rest-client-2.0.0-x86-mingw32/lib/restclient/resource.rb:65:in post': wrong number of arguments (0 for 1..2) (ArgumentError) from C:/Projects/Schema/test/examples/watson-api-client.rb:154:inrest_access_without_body' from (eval):2:in block (2 levels) in initialize' from watson_api_example_4th.rb:47:in

'

The version of rest-client is also the same result in 2.0 in 1.8.

I think if the patch is made the method 'rest_access_without_body', some similar patch should be necessary to the method 'rest_access_with_body'.

jesseproudman commented 8 years ago

Is watson_api_example_4th.rb available some where? The patched version I submitted works with the code I'm trying so it'd be great to see how you're kicking everything off.

The difference between rest_access_without_body is that it pushes as a HTTP GET so all the parameters need to be in the URL while rest_access_with_body is an HTTP POST.

suchowan commented 8 years ago

'watson_api_example_4th.rb' is just carrying out the example written in README.md simply. The above-mentioned exception occurs in RelationshipExtraction#extract. 'rest_access_without_body' handles cases of both of 'post' and 'get'. This is the specification of the Watson API side.

path = path +"?" + URI.encode_www_form(options)

It seems that this code should be performed on the rest-client gem side primarily. So I confirmed the internal code of rest-client gem. In case of 'get', 'options' probably seems to have to be nested by the key ':params'.

- path = path + "?" + URI.encode_www_form(options) - @service[path].send(access) + options = {:params=>options} if access.downcase == 'get' + @service[path].send(access, options)

It may work by correction like the above, could you check it?

Concerning about URL changes, it's best that the IBM side provides Swagger 2.0 version of the following URL(*). I requested it at several courses, but unfortunately have got no reactions yet.

(*) https://web.archive.org/web/20150903190650/http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/listings/api-docs.json

About the provision of the list of APIs, could you help me?

jesseproudman commented 8 years ago

You're correct. I've fixed that in #5.

I'm working inside IBM to try to get that master listing.