I’ve got only 403 Forbidden error
-
# 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.