wc-api-python
wc-api-python copied to clipboard
Fetching 'products' fails with a 403 error despite other successful API calls
Hello! Thanks for this library, though I'm having a little trouble retrieving products
specifically. I have no trouble retrieving e.g. orders
and customers
.
This works:
import os
from woocommerce import API
WOOCOMMERCE_API_CONSUMER_KEY = os.environ.get('WOOCOMMERCE_API_CONSUMER_KEY')
WOOCOMMERCE_API_CONSUMER_SECRET = os.environ.get('WOOCOMMERCE_API_CONSUMER_SECRET') # noqa
wcapi = API(
url='https://xxxxxxxx.org',
consumer_key=WOOCOMMERCE_API_CONSUMER_KEY,
consumer_secret=WOOCOMMERCE_API_CONSUMER_SECRET,
version='wc/v3',
user_agent='PostmanRuntime/7.26.5'
)
data = wcapi.get('orders')
# data = wcapi.get('customers')
print(data.status_code)
Trying wcapi.get('products')
, however, throws a 403
status code:
import os
from woocommerce import API
WOOCOMMERCE_API_CONSUMER_KEY = os.environ.get('WOOCOMMERCE_API_CONSUMER_KEY')
WOOCOMMERCE_API_CONSUMER_SECRET = os.environ.get('WOOCOMMERCE_API_CONSUMER_SECRET') # noqa
wcapi = API(
url='https://xxxxxxxx.org',
consumer_key=WOOCOMMERCE_API_CONSUMER_KEY,
consumer_secret=WOOCOMMERCE_API_CONSUMER_SECRET,
version='wc/v3',
user_agent='PostmanRuntime/7.26.5'
)
data = wcapi.get('products')
print(data.status_code)
Any help is much appreciated, thanks!
Confirmed that I have all product permissions:
I'm having the same issue. The code runs on 3 woo site without problems, and on one site I'm fetching this issue.
try using wp_api = True
in your api call