Hello,
I’m working on a Python script to determine coupon usage by my WooCommerce customers and issue new ones based on previously used coupons. Part of my logic requires me to obtain a list of WooCommerce order data for specific order IDs to extract coupon usage.
I read about using HTTP requests via Python (Code by Zapier) and have been stuck trying to figure out how to actually use the API correctly to make a GET request to my WooCommerce store.
I’ve tried searching through Google, Zapier forums, and read through the technical docs to find similar examples and instance, and tried many different kinds payload configurations but I can’t figure it out. It’s the last thing I need to sort out before I can deploy the pipeline.
References:
- https://docs.tectalic.com/woocommerce-zapier/developer-documentation/#rest-api-endpoints
- https://github.com/kennethreitz/requests/blob/v2.8.1/docs/user/quickstart.rst#make-a-request
Below is a shortened version of test code I have, what am I missing?
How can I go about updating my request for multiple order IDs? Loop and store into a variable?
import requests
payload = {
'Authorization': Basic CONSUMERKEY|CONSUMERPASSWORD,
'content-type': 'application/json'
}
# 25303 is an Order Id
response = requests.get('https://mywebsite.com/wp-json/wc-zapier/v1/orders/25303',headers=payload)