加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

如何从.net核心调用ibm watson api

发布时间:2020-12-14 00:32:27 所属栏目:Linux 来源:网络整理
导读:我试图调用watson个性洞察api,在环顾四周后,似乎解决方案是使.net等效于以下curl请求.我对此很陌生,想知道我是否可以获得指导或指向相关的教程. curl -X POST -u "{username}:{password}"--header "Content-Type: application/json"--data-binary @profile"h
我试图调用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>"
    );

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读