Python Forum
response 404 or 500 when trying to get products/sales from woocommerce using python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: response 404 or 500 when trying to get products/sales from woocommerce using python (/thread-41308.html)



response 404 or 500 when trying to get products/sales from woocommerce using python - wailoonho - Dec-17-2023

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?