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?

More than 3 years have passed since last update.

【BashでJSON】JSONファイルそのものをPOSTする

Last updated at Posted at 2021-07-24

概要

DRF(Django Rest Framework) に JSON ファイルを POST したら、宜しく解読してくれて驚いた.

詳細

POST 実行プログラム

引数に JSON ファイルへのパスを 1個指定する

#!/bin/bash
 
curl -X POST \
http://192.168.1.100:8000/api/v1/foo/result? \
-H "Content-Type: application/json" \
-d @$1

exit 0

JSON ファイル例

{
 "authors":"やなせたかし",
 "book":[
    {
        "title": "あんぱんまんとばいきんまん",
        "price": 935
    },
    {
        "title": "あんぱんまんとうみのあくま",
        "price": 935
    }
 ]
}
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?