mirror of
https://github.com/pi-hole/docs.git
synced 2024-12-06 19:27:12 +01:00
Directly add JSON payload instead of sourceing from file
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+3
-25
@@ -69,16 +69,7 @@ Name | Required | Type | Description | Default | Example
|
||||
-X POST \
|
||||
-H "Authorization: Token <your-access-token>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @body.json
|
||||
```
|
||||
|
||||
The content of `body.json` is like,
|
||||
|
||||
``` json
|
||||
{
|
||||
"status": "active",
|
||||
"delay": 30
|
||||
}
|
||||
-d '{"status":"active", "delay":30}'
|
||||
```
|
||||
|
||||
=== "Python 3"
|
||||
@@ -89,26 +80,13 @@ Name | Required | Type | Description | Default | Example
|
||||
URL = 'http://pi.hole:8080/admin/api/dns/blocking'
|
||||
TOKEN = '<your-access-token>'
|
||||
HEADERS = {'Authorization': f'Token {TOKEN}'}
|
||||
data = json.load(open('body.json', 'rb'))
|
||||
data = {"status":"active", "delay":30}
|
||||
|
||||
response = requests.post(
|
||||
URL,
|
||||
json=data,
|
||||
headers=HEADERS,
|
||||
)
|
||||
response = requests.post(URL, json=data, headers=HEADERS)
|
||||
|
||||
print(response.json())
|
||||
```
|
||||
|
||||
The content of `body.json` is like,
|
||||
|
||||
``` json
|
||||
{
|
||||
"status": "active",
|
||||
"delay": 30
|
||||
}
|
||||
```
|
||||
|
||||
!!! success "Response"
|
||||
|
||||
Response code: `HTTP/1.1 200 OK`
|
||||
|
||||
+3
-17
@@ -106,7 +106,7 @@ Name | Required | Type | Description | Default | Example
|
||||
-X PUT \
|
||||
-H "Authorization: Token <your-access-token>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @body.json
|
||||
-d '{"domain":"whitelisted.com", "enabled":true, "comment":"Some text"}'
|
||||
```
|
||||
|
||||
=== "Python 3"
|
||||
@@ -117,27 +117,13 @@ Name | Required | Type | Description | Default | Example
|
||||
URL = 'http://pi.hole:8080/admin/api/whitelist/exact'
|
||||
TOKEN = '<your-access-token>'
|
||||
HEADERS = {'Authorization': f'Token {TOKEN}'}
|
||||
data = json.load(open('body.json', 'rb'))
|
||||
data = {"domain":"whitelisted.com", "enabled":True, "comment":"Some text"}
|
||||
|
||||
response = requests.put(
|
||||
URL,
|
||||
json=data,
|
||||
headers=HEADERS,
|
||||
)
|
||||
response = requests.put(URL, json=data, headers=HEADERS)
|
||||
|
||||
print(response.json())
|
||||
```
|
||||
|
||||
The content of `body.json` is
|
||||
|
||||
``` json
|
||||
{
|
||||
"domain": "whitelisted.com",
|
||||
"enabled": true,
|
||||
"comment": "Some text"
|
||||
}
|
||||
```
|
||||
|
||||
!!! success "Success response"
|
||||
|
||||
Response code: `HTTP/1.1 201 Created`
|
||||
|
||||
Reference in New Issue
Block a user