{% if item.method in ['POST', 'PATCH'] %}const postData = {{ item.sample_body }};
{% endif %}fetch("{{ url_root }}{{ item.endpoint_example }}", {
method: "{{ item.method }}",
headers: {
'Content-Type': 'application/json',
}{% if item.method in ['POST', 'PATCH'] %},
body: JSON.stringify(postData){% endif %}
})
.then(response => response.json())
.then(data => {
console.log(data);
});
import requests
{% if item.method in ['POST', 'PATCH'] %}
post_data = {{ item.sample_body }};
response = requests.{{ item.method|lower }}(
'{{ url_root }}{{ item.endpoint_example }}',
json=post_data
)
print('Status Code:', response.status_code)
print(response.json()){% else %}
response = requests.{{ item.method|lower }}(
'{{ url_root }}{{ item.endpoint_example }}'
)
print('Status Code:', response.status_code)
print(response.json()){% endif %}