简体   繁体   中英

What is the correct REST API and authentication for IBM Watson Q and A service?

When I launch the Watson Question and Answer service in IBM Bluemix it comes with a set of credentials that include a User ID, Password and URL defined in the Q&A VCAP file.

I assume that that is the URL I should use when connecting to the Watson Q/A REST API and no other?

I also assume that the REST API for the Watson Q&A API that is documented on this link: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/#!/question-and-answer and that includes four REST API endpoints: GET V1/ping,
GET V1/services, POST /v1/question/{dataset} and
PUT /v1/feedback,

refers to the Q&A Service in Bluemix that I have just instantiated?

I should now be able to use Basic Authentication with 'username:password' and connect to the endpoints, where 'userid' and 'password', seperated by a colon, are the values contained in the VCAP file in Bluemix that I referred to, correct?

Finally, are there complete sample cURL scripts that access the GET V1/ping and the other three end-points of the Q&A Service?

You are correct in all your assumptions:

  • the url in your question_and_answer.credentials object is the API endpoint for the Q&A REST API.
  • that link is the Swagger API documentation for the Q&A service
  • the question_and_answer.credentials.username and question_and_answer.credentials.password contained in VCAP_SERVICES are meant to be used for Basic Auth

I do not know of a place where you can find comprehensive cURL scripts for all the API operations, but here is an example for the Q&A service question operation:

curl -X POST \
-u username:password \
-d "{\"question\": {\"evidenceRequest\": {\"items\": 1}, \"questionText\": \"How often should I wash my hands?\"}}"
https://gateway.watsonplatform.net/question-and-answer-beta/api/v1/question/healthcare/

This cURL requests asks Watson "How often should I wash my hands?" and only requests the answer with the most confidence.

The Watson Q and A Service has been discontinued:

https://developer.ibm.com/watson/blog/2015/11/11/watson-question-and-answer-service-to-be-withdrawn/

with all service ending December 16, 2015.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM