question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

wcapi.get('orders') returns 403

See original GitHub issue

I connect to my WooCommerce webshop through the WooCommerce REST API Python wrapper,

I.e,

from woocommerce import API

wcapi = API(
    url="https://mywebshop.whatever",
    consumer_key="ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    consumer_secret="cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    wp_api=True,
    version="wc/v1"
)

API has read/write access.

All worked fine for months up to yesterday.


Problem

Since yesterday latest_order = wcapi.get('orders').json() returns a JSONDecodeError: Expecting value. Also, wcapi.get('orders') returns a <Response [403]>.

I don’t know what’s causing this all of a sudden and I’m not sure how to solve it either.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
fnellencommented, Jun 6, 2022

When specifying the user_agent, the request goes through:

def testWCAPI():
    wcApi = API(
        url="https://www.XXX.org/",
        consumer_key=config("WOOCOMMERCE_KEY"),
        consumer_secret=config("WOOCOMMERCE_SECRET"),
        wp_api=True,
        version="wc/v3",
        user_agent="XXX.org"
    )
    orders = wcApi.get("orders").json()
    print(orders)
1reaction
claudiosanchescommented, Mar 16, 2021

This got fixed by https://github.com/woocommerce/wc-api-python/pull/57, thanks @Evert-Arends for your help. Note that I’ll release 3.0 soon, we’ll drop support to unsupported Python releases. The older releases of this lib seems to be still working with Python 2.7 in my tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Woocommerce REST API error 403 - WordPress.org
This error generally means that the server could find the resource, but unable to grant access to the requested resource for some reason....
Read more >
Wordpress API returns 403 for PUT only - Stack Overflow
Take a look at yout .htaccess file. If it looks like this: <Limit GET POST> order deny,allow deny from all allow from all...
Read more >
How to Fix a 403 Forbidden Error in WooCommerce?
This error is most commonly caused by permission issues—for example, when a file or directory is not writable by the web server's user...
Read more >
Introduction – WooCommerce REST API Documentation
GET /orders?offset=5. Page number is 1-based and omitting the ?page parameter will return the first page. The total number of resources and pages...
Read more >
Receiving 403 Forbidden When Using REST API In C# - Orion ...
If the credentials are wrong, you will get 403 Forbidden. ... MapStudioFiles WHERE IsDeleted = False ORDER BY FileName" $SwisConnection = Connect-Swis ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found