LoginSignup
0
4

More than 5 years have passed since last update.

PowerShellによるAPI通信を60秒で実装する

Last updated at Posted at 2017-12-11

Workflow

1.api.ps1(任意のファイル名)を作成
2.api.ps1をSampleに従って記述
3.api.ps1をダブルクリックして通信完了

Sample

api.ps1
# APIを実行
Invoke-RestMethod -Uri "実行するAPIのURL" -Method リクエスト方法 -Body @{パラメータの変数名="パラメータの値"}

Commentary

1. 実行するAPIのURL
APIを用意してくれているURLを入力します。
郵便番号から住所を割り出すAPIは、一般的に簡単なのでテストに丁度良いです。

2. リクエスト方法
大体POSTかGETです。

3. @{パラメータの変数名="パラメータの値"}
よくあるパラメータです。
郵便番号とかだと@{zipcode="123-4567"}みたいな感じで書きます。

Reference

Windowsにcurlが無い?いいえ、Invoke-RestMethodがあります。GrailsアプリへのPOSTリクエストを試す
PowerShell > Link > PSのバージョンを確認する > $PSVersionTable < Invoke-RestMethod と ConvertTo-Json が見つからないエラー
Web APIを利用する

0
4
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
4