woocommerce / woocommerce/wc-api-python
response.status_code on insert a product
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 216
- Forks
- 108
- Avg merge
- 6h 34m
- Merged PRs (30d)
- 1
Description
I have been trying to use a simple code to post a product on WooCommerce from Python.
Im trying this code:
import sys
import googlemaps
from woocommerce import API
import base64
wcapi = API(
url="https://mysite.com",
consumer_key="ck_e6*********************************b9c5", # Your consumer key
consumer_secret="cs_3e*********************************e7de19", # Your consumer secret
wp_api=True, # Enable the WP REST API integration
version="wc/v3", # WooCommerce WP REST API version
query_string_auth=True,
timeout=10
)
data = {
"name": "Premium Quality",
"type": "simple",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
}
response = wcapi.post("products", data)
print("Status: ", response.status_code)
if response.status_code == 201:
print("Success")
else:
print("Error")
# print(response.text)
sys.exit()
I have gotten the "200" status.
Notthing was post on woocommerce.
After i tryed delete with the code:
print(wcapi.delete("products/108", params={"force": True}).json())
And deleted success.
Where am I going wrong?
Tks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the wcapi.post("products", data) call from the issue and inspect the returned status and body, then compare it with the subsequent wcapi.delete("products/108", params={"force": True}) call. Done means identifying why the insert reports 200 without creating the product and documenting or correcting the relevant behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100