Skip to content

response.status_code on insert a product #99

Description

@dinhopereira

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions