14
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HTTPリクエストのGET/POSTをショートカット(iOS)とcURL(コマンド)で比較

Posted at

HTTPリクエスト GET/POST

HTTPのGETをサーバーから情報を取得してきます。JSONファイルなどを返してくれる
HTTPのPOSTはサーバーに情報を送ります。特に返ってくるものはない(成功、失敗が返ってくることがある)
ダウンロード(GET)、アップロード(POST)が可能です。

ショートカット(iOS)

ショートカットとはWorkflowがAppleNi買収されiOS 12から利用可能になったiOS標準のアプリです。
実は多くのことができるのですが、今回はHTTPのGET/POSTをやっていきます。

cURL

「curl」コマンドは、さまざまなプロトコルに対応したデータを転送するためのコマンドです。

HTTP GET

cURL

curl -X GET "https://example.com/api/" -H "accept: application/json" -H "Content-Type: form"

ショートカット

使用するショートカットのアクションはURLの内容を取得です。
方法をGETにすることでHTTPのGETが利用可能です。
cURLの「-H」headerヘッダから設定可能です。

HTTP POST

cURL

curl -X POST "https://example.com/api/" -H "accept: application/json" -d "temperature=18" -d "operation_mode=auto"

ショートカット

使用するショートカットのアクションはURLの内容を取得です。
方法をPOSTにすることでHTTPのPOSTが利用可能です。
cURLの「-d」data本文を要求フォームから設定可能です。

14
6
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
14
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?