• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio 
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • WordPress AI Features
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio  
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • WordPress AI Features
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / I’ve got only 403 Forbidden error

I’ve got only 403 Forbidden error

  • Unknown's avatar
    s113488 · Member · Jun 24, 2024 at 3:02 am
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites
    # WordPress username and password
            username = "s113488"
            password = "xxxx xxxx xxxx xxxx"
            print(
                base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
            )
            # Open the image file in binary mode
            with open(result["Featured Image"], "rb") as img:
                # Prepare the headers for the REST API request
                headers = {
                    "Content-Disposition": f'attachment; filename={os.path.basename(result["Featured Image"])}',
                    "Content-Type": "image/png",  # Adjust this if your images are not PNGs
                    "Authorization": "Basic "
                    + base64.b64encode(f"{username}:{password}".encode("utf-8")).decode(
                        "utf-8"
                    ),
                }
    
                # Send the POST request to the WordPress REST API
                response = requests.post(
                    f"https://public-api.wordpress.com/rest/v1.1/sites/reviewpass.wordpress.com/media/new",
                    headers=headers,
                    data=img,
                )
    
            # If the request was successful, the image ID will be in the response
            if response.status_code == 201:
                image_id = response.json()["id"]
            else:
                print(f"Error uploading image: {response.status_code}")
    

    This is my code. I got my password from https://wordpress.com/me/security/two-step

    which gives me an application password.

    and I requested with my username and password. but Response is always “Error uploading image: 403” Is it because I’m using a free plan?

    The blog I need help with is: (visible only to logged in users)

  • The topic ‘I’ve got only 403 Forbidden error’ is closed to new replies.

Tags

  • account
  • design
  • images

About this topic

  • In: Support
  • 1 participant
  • 0 replies
  • Last activity 2 years
  • Latest reply from s113488

Have a question?

Get in touch
Back to Top

Couldn't find what you needed?

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • WordPress AI Features
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions