• 追加された行はこの色です。
  • 削除された行はこの色です。
#author("2019-06-14T14:13:13+09:00","default:ryuichi","ryuichi")
#author("2019-06-15T07:36:32+09:00","default:ryuichi","ryuichi")
* curl.exeに渡すPOSTデータで予期せぬ引用符の展開を防ぐ [#l0f9aabf]

** 変数にPOSTデータを入れておく (PowerShell) [#ofb6a0bd]

 # あらかじめtest.jsonにPOSTデータを書いておく
 
 $json = @'
 {
   "foo": 1,
   "bar": [1, 2, 3]
 }
 '@
 $json | curl.exe -H "Content-Type: application/json" -XPOST http://test.com/ -d@-

- -d@-を指定すると標準入力を読み取る
- ただこの方法だと日本語で問題が起きる気がする

** ファイルにPOSTデータを書いておく [#xa297cee]
 notepad.exe test.json
 curl.exe -H "Content-Type: application/json" -XPOST http://test.com/ -d@'test.json'

- 多分簡単で確実な方法はこれというか、これしかない


** 参考 [#bf084317]

- https://stackoverflow.com/questions/4514199/how-to-send-double-quote-in-d-parameter-for-curl-exe
- https://curl.haxx.se/docs/manpage.html



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS