-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocument.py
More file actions
31 lines (25 loc) · 754 Bytes
/
document.py
File metadata and controls
31 lines (25 loc) · 754 Bytes
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
import requests
import json
import os
import base64
def test_senddoc():
api_endpoint = "http://localhost:8080/senddoc"
bearer_token = "your_secret_token"
req_data = {
"to": "yournumber",
"caption": "Test document",
"filename": "document.docx",
}
temp_file = "test.docx"
with open(temp_file, "rb") as f:
file_data = f.read()
encoded_data = base64.b64encode(file_data).decode("utf-8")
req_data["document"] = encoded_data
headers = {
"Authorization": f"Bearer {bearer_token}",
"Content-Type": "application/json"
}
response = requests.post(api_endpoint, headers=headers, json=req_data)
print(response.text)
if __name__ == "__main__":
test_senddoc()