Skip to content

Making HTTP Requests

1. Making HTTP Requests / Calling external APIs

# GET request
ping_endpoint = ""
response = frappe.make_get_request(ping_endpoint)
print(response) # {'message': 'pong'}

The above script makes a GET HTTP request to some other Frappe site.

2. Making POST HTTP Request with API Authentication Headers

# POST request
todo_endpoint = ""
api_token = "<api-key>:<api-secret>"
headers = {"Authorization": f"token {api_token}"}
data = {"description": "Build something with Hussain"}
response = frappe.make_post_request(todo_endpoint, data=data, headers=headers)
print(response) # created ToDo doc