MCPcopy
hub / github.com/sparckles/Robyn / json_post

Function json_post

integration_tests/helpers/http_methods_helpers.py:64–85  ·  view source on GitHub ↗

Makes a POST request with JSON body to the given endpoint and checks the response. endpoint str: The endpoint to make the request to. json_data: The JSON-serializable data to send with the request (dict, list, etc.). expected_status_code int: The expected status code of the respons

(
    endpoint: str,
    json_data=None,
    expected_status_code: int = 200,
    headers: dict = {},
    should_check_response: bool = True,
)

Source from the content-addressed store, hash-verified

62
63
64def json_post(
65 endpoint: str,
66 json_data=None,
67 expected_status_code: int = 200,
68 headers: dict = {},
69 should_check_response: bool = True,
70) -> requests.Response:
71 """
72 Makes a POST request with JSON body to the given endpoint and checks the response.
73
74 endpoint str: The endpoint to make the request to.
75 json_data: The JSON-serializable data to send with the request (dict, list, etc.).
76 expected_status_code int: The expected status code of the response.
77 headers dict: The headers to send with the request.
78 should_check_response bool: A boolean to indicate if the status code and headers should be checked.
79 """
80
81 endpoint = endpoint.strip("/")
82 response = requests.post(f"{BASE_URL}/{endpoint}", json=json_data, headers=headers)
83 if should_check_response:
84 check_response(response, expected_status_code)
85 return response
86
87
88def json_put(

Calls 2

check_responseFunction · 0.70
postMethod · 0.45