0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure AI Language の Custom question answering の API をPowerShell で実行する

0
Posted at

この記事の目的

公式ドキュメントにはリファレンスが記載されているが、実行するとき毎回変換する必要があるため、備忘の為、記載する

実行するAPI

Azure AI Language / Custom question answering のREST API である Question Answering - Get Answers APIを実行する

Language Studio のテスト時に実行されているAPI
image.png

実行方法

PowerShell の Invoke-RestMethod を使用して実行する

実行例

$key = "<api key>"
$Resource = "<Resource 名>"
$ProjectName = "<プロジェクト名>"
$DeploymentName = "<デプロイメント名>" #Studioと同じなら"test"
$apiversion = "<REST APIのバージョン>" #Stuioと同じなら"2021-10-01"
$url = "https://$Resource.cognitiveservices.azure.com/language/:query-knowledgebases?projectName=$ProjectName&api-version=$apiversion&deploymentName=$DeploymentName"
$headers = @{}
$headers["Content-Type"]  = "application/json"
$headers["Ocp-Apim-Subscription-Key"] = "$key"
$body = '{
  "question": "How do I setup my surface book?"
}'

$response = Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body $body
$response | Format-List

key などの取得方法はこちらを参照

APIのバージョンはREST APIのリファレンスを参照

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?