This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CURL CHEAT SHEET
110 lines (59 loc) · 2.28 KB
/
CURL CHEAT SHEET
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
curl http://127.0.0.1:8000/snippets/ \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"pk": "1","title": "first post","code": "print hello world"}' \
| python -m json.tool
curl http://127.0.0.1:8000/snippets/ \
-X GET \
-H "Accept: application/json" \
| python -m json.tool
curl http://127.0.0.1:8000/snippets/ \
-X GET \
-H "Accept: text/html"
curl http://127.0.0.1:8000/snippets/ \
-X GET \
-H "Accept: text/html,application/json"
----------cookies\\
curl http://127.0.0.1:8000/snippets/ \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: text/html,application/json" \
-H "X-CSRFToken: 4yrCkYK3zmQZha3KrwtFQTqFBnyc4b9N" \
-H "Cookie: csrftoken=4yrCkYK3zmQZha3KrwtFQTqFBnyc4b9N" \
-u tawanda:admin \
-d '{"title": "first cookie post","code": "print hello world"}'
curl http://127.0.0.1:8000/snippets/8/ \
-X DELETE \
| python -m json.tool
####################### USING HTTPIE ##############################
----------intro
http PATCH api.example.com/person/1 X-API-Token:123 name=John email=john@example.org age:=29
The following request is issued::
PATCH /person/1 HTTP/1.1
User-Agent: HTTPie/0.1
X-API-Token: 123
Content-Type: application/json; charset=utf-8
{"name": "John", "email": "john@example.org", "age": 29}
----------post
$ http POST example.com/posts/3 \
Origin:example.com # : HTTP headers
name="John Doe" \ # = string
q=="search" \ # == URL parameters (?q=search)
age:=29 \ # := for non-strings
list:='[1,3,4]' # := json
token=@token.txt \ # =@ read from file (text)
user:=@user.json \ # :=@ read from file (json)
----------Forms
$ http --form POST example.com \
name="John Smith" \
cv=@document.txt
---------EXAMPLE-----------------
http --timeout=3600 POST http://127.0.0.1:8000/snippets/ 'title'='more new stuff' 'code'='more test code'
--------EXAMPLE 2 *************not working
http --timeout=3600 POST http://127.0.0.1:8000/snippets/ \
Accept: text/html,application/xhtml+xml \
Cookie: sessionid=kk0b0zaqydq74ej0d6zxspr6b8df6g71; tabstyle=html-tab; csrftoken=4yrCkYK3zmQZha3KrwtFQTqFBnyc4b9N \
'title'='first cookie post'\
'code'='hellow world again'
http://localhost:63343/