Python Forum

Full Version: response 404 or 500 when trying to get products/sales from woocommerce using python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I'm trying to get product and sales data from woocommerce using python

here is my code

import json
from woocommerce import API

wcapi = API(
url="https://abc",
consumer_key="ck_abc",
consumer_secret="cs_abc",
version="wc/v3",
timeout=50
)

response = wcapi.get('products', params={'per_page': 20})
print(response)
and I got this error

Error:
Exception has occurred: JSONDecodeError Expecting value: line 1 column 1 (char 0) StopIteration: 0 During handling of the above exception, another exception occurred: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: File "X:\test.py", line 16, in <module> print(wcapi.get("products", params={"per_page": 20}).json()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
May I know what have i done wrong?