我试图调用watson个性洞察api,在环顾四周后,似乎解决方案是使.net等效于以下curl请求.我对此很陌生,想知道我是否可以获得指导或指向相关的教程.
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"
解决方法
您可以使用
Watson Developer Cloud .NET Standard SDK.使用NuGet安装Personality Insights服务
Install-Package IBM.WatsonDeveloperCloud.PersonalityInsights -Pre
实例化服务
// create a Personality Insights Service instance PersonalityInsightsService _personalityInsights = new PersonalityInsightsService(); // set the credentials _personalityInsights.SetCredential("<username>","<password>");
致电该服务
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>" );
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。