How to call ibm watson api from .net kernel

I'm trying to call watson person insight api, looking around, it seems like the solution is to make the .net equivalent of the next curl request. I am new to this and have been wondering if I can get guidance or point to relevant textbooks.

curl -X POST -u "{username}:{password}"
--header "Content-Type: application/json"
--data-binary @profile
"https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2016-10-20&consumption_preferences=true&raw_scores=true"
+4
source share
2 answers

You can use the Watson Developer Cloud.NET Standard SDK . Install NuGet Identity Service using

Install-Package IBM.WatsonDeveloperCloud.PersonalityInsights -Pre

Activate the service

// create a Personality Insights Service instance
PersonalityInsightsService _personalityInsights = new PersonalityInsightsService();

// set the credentials
_personalityInsights.SetCredential("<username>", "<password>");

Service call

var results = _personalityInsights.GetProfile(ProfileOptions.CreateOptions()
                                                         .WithTextPlain()
                                                         .AsEnglish()
                                                         .AcceptJson()
                                                         .AcceptEnglishLanguage()
                                                         .WithBody("some text"));

, , .

var results = _personalityInsights.GetProfile(
        "<input>", 
        "<content-type>", 
        "<content-language>", 
        "<accept>", 
        "<accept-language>",
        "<raw-scores>",
        "<csv-headers>"
        "<consumption-preferences>",
        "<version>"
    );
+5

curl API? ...

, username password, , . API HTTP.

curl -u "{username}":"{password}"
"https://gateway.watsonplatform.net/personality-insights/api/v3/{method}"

Bluemix Watson.

:

curl -u "{username}":"{password}"
--header "X-Watson-Learning-Opt-Out: true"
"https://gateway.watsonplatform.net/personality-insights/api/v3/{method}"

:

curl -X POST -u "{username}:{password}"
--header "Content-Type: application/json"
--data-binary @profile.json
"https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2016-10-20&consumption_preferences=true&raw_scores=true"

IBM Watson API HTTP .

  • 200 .

  • 400 - .

  • 500 .

IBM , , . this , .

, fork github, .

+2

Source: https://habr.com/ru/post/1673183/


All Articles