• Resolved maurochuchuy

    (@maurochuchuy)


    I have a python script that will update stock status and price of my products based on data from a different website.

    I have created and API that was first assigned to an administrator profile in my woocommerce account and then to a shop manager profile (I tested this based on an answer I found here).
    I am still getting the following error while trying to update the products:

    Traceback (most recent call last):
    File “c:\Users\scraper.py”, line 134, in
    products.raise_for_status()
    File “C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py”, line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://lasmarias.ar/wp-json/wc/v3/product

    I have manually accessed the above url using the client and secret and was able to get a response.

    Also disabled my plugins and that did not work

    Have also compared headers from a manual request and my script and they do match. At this point I’m lost for options.

    Would appreciate your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @maurochuchuy

    Thanks for reaching out!

    This is a fairly complex development topic that would require customization to do it. Since custom coding is outside our scope of support, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

    Thread Starter maurochuchuy

    (@maurochuchuy)

    Hi there @xue28 and thank you for your recommendations and leaving the topic open for someone else to jump in.

    I was under the impression that since I was getting a 403 error, I could get an answer with a few ideas on what I could troubleshoot since for some reason I’m denied access even with the right keys and making sure the json product url is working when I try a manual request.

    I also thought It could be a php version issue but updating my php on my server would brake other websites and for the time being Im trying to avoid that.

    Anyways, Ill wait and see If someone can jump in and will also try and reach out for help on the forums you suggested.

    Thanks!

    Roxy

    (@roxannestoltz)

    Hi @maurochuchuy ,

    This error message suggests that the API request is being rejected by the server with a “Forbidden” (403) error. There are a few possible reasons for this:

    1. Incorrect API credentials: Double-check that you have entered the correct API key and secret for the profile you are using.
    2. Permission issue: Make sure that the profile you are using has the necessary permissions to update products.
    3. Rate limiting: Check if the API has a rate limit and if your script is exceeding it.
    4. Endpoint restriction: The API endpoint may be restricted to specific IP addresses or referrers. Check to see if this is the case, and if so, ensure that the request is being sent from an allowed IP or referrer.
    5. Security plugin: Some security plugins may block API requests. Disable any security plugins temporarily to see if they are causing the issue.
    6. Verify SSL certificate: Ensure that your script is verifying the SSL certificate of the API endpoint to avoid any potential issues with untrusted or invalid certificates.
    7. Debug logging: Check the server logs for any additional information that may help you troubleshoot the error.
    8. Verify server requirements: Make sure that your server meets the minimum requirements for the API, such as PHP version and modules.

    Hope this helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘HTTPError: 403 Client Error: Forbidden’ is closed to new replies.