| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Flask
- KAKAO
- pytorch
- 책갈피
- Package
- evaluation
- DB
- GitLab
- format
- Paper
- judge
- Python
- Mac
- docker
- AI
- Container
- numpy
- TORCH
- Converting
- pandas
- PostgreSQL
- git
- Laravel
- Windows
- file
- ubuntu
- LLM
- Linux
- Database
- list
Archives
- Today
- Total
Daily Develope
[Request] Content-Type의 데이터별 http 요청(requests) 코드 예제 본문
application/json
O Curl
$ curl -x POST \
-h 'Content-Type: application/json' \
-h 'x-client-key: my-sample-key' ... \
-d '{"data1":"value1","data2":{"data21":"value21"},"data3":["value31","value32"]}' \
https://mydomain.com/some-api/sample
O Python
import requests
_url = "https://mydomain.com/some-api/sample"
_headers = {
"Content-Type": "application/json",
"x-client-key": "my-sample-key",
... }
_data = {"data1":"value1","data2":{"data21":"value21"},"data3":["value31","value32"]}
res = requests.post(url=_url, headers=_headers, json=_data)
application/octet-stream
O Curl
$ curl -x POST \
-h 'Content-Type: application/json' \
-h 'x-client-key: my-sample-key' ... \
-d '{\"data1\":\"value1\",\"data2\":{\"data21\":\"value21\"},\"data3\":[31,\"value32\"]}' \
https://mydomain.com/some-api/sample
O Python
import requests
_url = "https://mydomain.com/some-api/sample"
_headers = {
"Content-Type": "application/json",
"x-client-key": "my-sample-key",
... }
_data = '{\"data1\":\"value1\",\"data2\":{\"data21\":\"value21\"},\"data3\":[31,\"value32\"]}'
res = requests.post(url=_url, headers=_headers, data=_data.encode("utf8"))'Develope > Web' 카테고리의 다른 글
| [Web] curl & program code 변환 (관련링크) (0) | 2023.03.27 |
|---|---|
| [Web] Multipart/form-data 요청(Request) in Python (0) | 2023.03.27 |
| [HTTP] 응답 상태코드 (response status code) (0) | 2022.08.17 |
| [FLASK] request 정리 (0) | 2022.08.16 |
| [WEB] TODO - RestAPI 정리 (0) | 2022.08.08 |
Comments