"Autoit curl"의 두 판 사이의 차이
DB CAFE
(→윈도우 파알 다운로드) |
|||
26번째 줄: | 26번째 줄: | ||
== curl 사용법 == | == curl 사용법 == | ||
− | |||
− | + | === 자주 사용하는 옵션 3가지 === | |
− | - | + | -d, --data: <data> Send specified data in POST request. |
+ | -H, --header: <header> Headers to supply with request. | ||
+ | -X, --request: The request method to use. ex) GET, POST | ||
− | + | [GET방식] | |
+ | <source lang=shell> | ||
+ | curl -d "key1=value1&key2=value2" \ | ||
+ | -H "Content-Type: application/x-www-form-urlencoded" \ | ||
+ | -X GET http://localhost:8000/data | ||
+ | </source> | ||
− | + | [POST방식] | |
+ | <source lang=shell> | ||
+ | [URL형식 데이터] | ||
+ | curl -d "key1=value1&key2=value2" \ | ||
+ | -H "Content-Type: application/x-www-form-urlencoded" \ | ||
+ | -X POST http://localhost:8000/data | ||
+ | [JSON형식 데이터] | ||
+ | curl -d '{"key1":"value1", "key2":"value2"}' \ | ||
+ | -H "Content-Type: application/json" \ | ||
+ | -X POST http://localhost:8000/data | ||
+ | </source> | ||
− | + | # 원도우 curl에서는 '를 "로 변경하고, "를 ""로 변경하고 호출해야한다. | |
− | + | <source lang=shell> | |
− | + | curl -d "{""key1"":""value1"", ""key2"":""value2""}" \ | |
− | + | -H "Content-Type: application/json" \ | |
− | ' | + | -X POST http://localhost:8000/data |
− | + | </source> | |
− | " | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
2020년 4월 8일 (수) 17:36 판
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
1 윈도우용 다운로드[편집]
64bit https://curl.haxx.se/windows/dl-7.69.1_1/curl-7.69.1_1-win64-mingw.zip
32bit https://curl.haxx.se/windows/dl-7.69.1_1/curl-7.69.1_1-win32-mingw.zip
2 autoit 적용 소스[편집]
Dim $iPidCurl = Run(@ComSpec & " /c " & 'curl -i -H' & 'Content-Type: application/x-www-form-urlencoded' & 'https://api.edmunds.com/inventory/token' & '-X POST -d ' & 'client_id=<MY SECRET ID >'&' -d ' & 'client_secret=<MY SECRET PHRASE>' & ' -d ' &'grant_type=client_credentials', @ScriptDir, @SW_HIDE,2+4)
Dim $sOut
While 1
$sOut &= StdoutRead($iPidCurl)
If @error Then ExitLoop
WEnd
While 1
$sOut &= StderrRead($iPidCurl)
If @error Then ExitLoop
WEnd
ConsoleWrite($sOut&@LF&"*********"&@LF)
3 curl 사용법[편집]
3.1 자주 사용하는 옵션 3가지[편집]
-d, --data: Send specified data in POST request. -H, --header: <header> Headers to supply with request. -X, --request: The request method to use. ex) GET, POST
[GET방식]
curl -d "key1=value1&key2=value2" \
-H "Content-Type: application/x-www-form-urlencoded" \
-X GET http://localhost:8000/data
[POST방식]
[URL형식 데이터]
curl -d "key1=value1&key2=value2" \
-H "Content-Type: application/x-www-form-urlencoded" \
-X POST http://localhost:8000/data
[JSON형식 데이터]
curl -d '{"key1":"value1", "key2":"value2"}' \
-H "Content-Type: application/json" \
-X POST http://localhost:8000/data
- 원도우 curl에서는 '를 "로 변경하고, "를 ""로 변경하고 호출해야한다.
curl -d "{""key1"":""value1"", ""key2"":""value2""}" \
-H "Content-Type: application/json" \
-X POST http://localhost:8000/data