GPT failed to connect to an API but the connection works locally

I am trying to have a custom GPT connect to my wordpress website and publish a new post. I have verified the schema I created works for

  1. connecting and authenticating to the api
  2. correctly submitting the article title, content, slugs, etc
  3. correctly uploading an image to the correct endpoint

Each time I run the GPT and get to the step where it uploads the image to the correct location on wordpress I get an error that the username/password was incorrect. Running a curl command locally shows the username and application password is actually correct.

I hardcoded the wordpress URL, username, and application password to a file that I uploaded to the GPT so I can be sure. I then asked it to try again while outputting the full analysis of its attempt. The following is the simple auth script it is executing with the username , url, and password omitted:

import requests
import base64
import json

# Load the authentication details from the '' file.
# For security reasons, the content of this file is not displayed or accessible directly.
# Instead, we use the provided information to authenticate and interact with the WordPress API.

# Assuming '' contains the necessary credentials and URL for the WordPress site
wordpress_url = [omitted]
app_username =  [omitted]
app_password =  [omitted]
# Encode the credentials using Base64
credentials = f"{app_username}:{app_password}"
token = base64.b64encode(credentials.encode())
header = {'Authorization': f'Basic {token.decode()}'}

# Prepare the image file for upload
image_filename = 'C:\\Users\\me\\Downloads\\855af5.jpg'
image_data = open(image_filename, 'rb').read()

# Construct the request for media upload
media_url = f"{wordpress_url}/wp/v2/media"
media_headers = {
    'Authorization': header['Authorization'],
    'Content-Disposition': 'attachment; filename="855af5.jpg"',
    'Content-Type': 'image/png',
response =, headers=media_headers, data=image_data)

# Check the response status and handle accordingly
if response.status_code == 201:
    image_id = response.json()['id']
    print("Image uploaded successfully. Image ID:", image_id)
    print("Failed to upload image. Status Code:", response.status_code, "Response:", response.text)

This gave me a network resolution error from the GPT; however, running this script locally with the values hardcoded resulted in the image successfully uploading. Is wordpress blocking the GPT connection to the API? What could possibly be causing this issue?

Are you trying to have the GPT run this code in the interpreter? If so, I think that might be a problem. Pretty sure that it is sandboxed with no external connections.

1 Like

I’ve tried both the code interpreter and additionally by adding an ‘Action’ with an openapi schema configured for Wordpress. Neither seem to be working from the GPT but I confirmed it does work locally.

I am puzzled by why it is not working when I use the schema. Sometimes it gives a 401 error wrong username/password , then when I hardcoded the credentials it began saying connection timeout failure to resolve. That error to me means environment issues but why? What can I really do to resolve?

Thanks for your reply

There seems to have been a temporary outage this afternoon and now it’s calling a lot of actions but none succeeds.

Hmmm Ok I will try again and provide an update if it works for me in the am. Thanks @tamas.simon

use Plugin ( JWT Auth – WordPress JSON Web Token Authentication)