# "HTTP Request Block Failing with 401 Unauthorized Error"

**URL:** <https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585>\
**Category:** Support\
**Created:** [August 29, 2025, 10:11am UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585 "2025-08-29T10:11:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramelton](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ramelton](https://community.mindstudio.ai/u/ramelton)\
**Post date:** [August 29, 2025, 10:11am UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/1 "2025-08-29T10:11:13Z")

</div>

“I have a workflow that uses the `HTTP Request` block to make a `POST` call to an external WordPress API. The call is failing with a `401 Unauthorized` error (`rest_cannot_create`).”

### Troubleshooting Steps Taken

"To troubleshoot this, I performed the following tests, which have ruled out all issues on my end:

1. **Tested the API and Credentials directly:** I used a separate API client (Postman) to make the exact same `POST`request to the WordPress API. This test **succeeded** with a `201 Created` response. This confirms that the API endpoint is working, my credentials are correct, and there are no server-side firewall or plugin conflicts.

2. **Confirmed the generated JSON:** I verified that the `Generate Text` block is producing a correctly formatted JSON payload.

3. **Removed all variables from the HTTP Request:** I created a new workflow with a hardcoded `Authorization`header and a hardcoded JSON body (pasted directly from the successful Postman test). This test **failed** with the same `401 Unauthorized` error. This proves that the issue is not related to dynamic variables or how the AI is generating the content.

### Conclusion

“Based on these results, it appears there is an issue with how the MindStudio `HTTP Request` block is sending the request, possibly due to a bug where it’s adding unseen parameters or headers that are causing the request to be rejected by the server.”

---

<div class="post-metadata">

**Author:** ![ramelton](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ramelton](https://community.mindstudio.ai/u/ramelton)\
**Post date:** [August 29, 2025, 10:18am UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/2 "2025-08-29T10:18:56Z")

</div>

![1](https://canada1.discourse-cdn.com/flex008/uploads/mindstudio/original/1X/9444a57f545cc1ca9d8b469818281d6bf93da738.jpeg)

There is the full run with password removed

---

<div class="post-metadata">

**Author:** ![sean](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sean](https://community.mindstudio.ai/u/sean)\
**Post date:** [August 29, 2025, 11:23am UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/3 "2025-08-29T11:23:27Z")

</div>

Can you please share a link to the agent and I can take a look?

---

<div class="post-metadata">

**Author:** ![ramelton](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ramelton](https://community.mindstudio.ai/u/ramelton)\
**Post date:** [August 29, 2025, 11:52am UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/4 "2025-08-29T11:52:31Z")

</div>

Hi Sean

Here it is [https://app.mindstudio.ai/agents/test-run-5005170f/run/cdda67aa-956b-47a0-81ab-05e9f83f4061](https://app.mindstudio.ai/agents/test-run-5005170f/run/cdda67aa-956b-47a0-81ab-05e9f83f4061)

**Run Details**

Run ID

7d8ebe1b-a9c7-4523-a97b-d7e961322d43

Source

Manually run by user

User ID

b21dd327

---

<div class="post-metadata">

**Author:** ![sean](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sean](https://community.mindstudio.ai/u/sean)\
**Post date:** [August 29, 2025, 12:23pm UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/5 "2025-08-29T12:23:09Z")

</div>

Hmm, I can verify everything looks fine here. Could you share the code snippet generated by Postman? On the right side there should be a little \</\> icon that you can click and it will show something like this:

 ![image](https://canada1.discourse-cdn.com/flex008/uploads/mindstudio/original/1X/26860ec3961d89a3955b08c90ad1edff667c9e66.png)

---

<div class="post-metadata">

**Author:** ![ramelton](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ramelton](https://community.mindstudio.ai/u/ramelton)\
**Post date:** [August 29, 2025, 12:38pm UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/6 "2025-08-29T12:38:24Z")

</div>

Hi Sean there it is

curl --location ‘[https://wpfoodieschool.com/wp-json/wp/v2/wprm\_recipe](https://wpfoodieschool.com/wp-json/wp/v2/wprm_recipe)’ \

--header ‘Content-Type: application/json’ \

--header ‘Authorization: ••••••’ \

-- **data**'{

“status”: “publish”,

“wprm\_recipe”: {

“name”: “API Test Recipe”,

“summary”: “This recipe was created via a direct API call.”

}

}’

---

<div class="post-metadata">

**Author:** ![Alex\_MindStudio](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.mindstudio.ai/alex_mindstudio/32/27_2.png) [@Alex\_MindStudio](https://community.mindstudio.ai/u/Alex_MindStudio)\
**Post date:** [September 5, 2025, 1:44pm UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/7 "2025-09-05T13:44:13Z")

</div>

Hi @ramelton,

Here’s a quick guide on how to get the WP Recipe Maker working with MindStudio’s HTTP Request block:

**1. Prep WordPress**

1. Install & activate WP Recipe Maker
2. Go to Users → Profile → Application Passwords
3. Generate a new one (e.g. “MindStudio”) and copy it exactly (spaces included)
4. Copy your username (e.g. “3xte3dr6abq5”)

**2. Configure HTTP Request block**

1. Method: POST
2. URL: [https://yourdomain.com/wp-json/wp/v2/wprm\_recipe](https://yourdomain.com/wp-json/wp/v2/wprm_recipe)
3. Headers:  
Accept: application/json  
User-Agent: Mozilla/5.0  
Content-Type: application/json  
Authorization: Basic \<your\_base64\_string\>

Alternatively, you can create a Custom Function to generate the Authorization header value:

Code:

```auto
// Validate required inputs
if (!ai.config.wordpressUsername?.trim()) {
  throw new Error('WordPress username is required');
}

if (!ai.config.wordpressPassword?.trim()) {
  throw new Error('WordPress application password is required');
}

// Generate Basic auth header
const username = ai.config.wordpressUsername.trim();
const password = ai.config.wordpressPassword.trim();
const credentials = `${username}:${password}`;

// Base64 encode the credentials
const encodedCredentials = btoa(credentials);
const authHeader = `Basic ${encodedCredentials}`;

// Log the generated headers
console.log('Generated Authorization header');

// Set output variables
ai.vars[ai.config.authHeader] = authHeader;

```

Configuration:

```auto
config = {
  transitionType: 'controlled',
  metadata: {
    name: 'Generate WordPress API Headers',
    description: 'Generates authentication headers for WordPress API requests',
  },
  blockStyle: {
    label: 'Generate WP Headers',
  },
  configurationSections: [
    {
      title: 'WordPress Authentication',
      items: [
        {
          label: 'WordPress Username',
          type: 'text',
          variable: 'wordpressUsername',
          helpText: 'Your WordPress API username',
          placeholder: 'e.g., 3xte6da4abq2',
        },
        {
          label: 'WordPress Application Password',
          type: 'text',
          variable: 'wordpressPassword',
          helpText: 'Your WordPress application password (spaces allowed)',
          placeholder: 'e.g., 4c8A eBnX ALMw QXk8 1NF7 3dQy',
        },
      ],
    },
    {
      title: 'Output Variable Names',
      items: [
        {
          label: 'Authorization Header Variable',
          type: 'outputVariableName',
          variable: 'authHeader',
          helpText: 'The variable name for the Basic authentication header',
        }
      ],
    },
  ],
}

```

1. Content Type: application/json
2. Body:

```auto
{
  "status": "publish",
  "title": "Best Banana Bread",
  "content": "This recipe was created via MindStudio REST API.",
  "wprm_recipe": {
  "name": "Best Banana Bread"
  }
}

```

---

<div class="post-metadata">

**Author:** ![ramelton](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ramelton](https://community.mindstudio.ai/u/ramelton)\
**Post date:** [September 5, 2025, 4:32pm UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/8 "2025-09-05T16:32:52Z")

</div>

Hi Alex, thanks very much I got it working.

---

<div class="post-metadata">

**Author:** ![ramelton](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@ramelton](https://community.mindstudio.ai/u/ramelton)\
**Post date:** [September 5, 2025, 4:33pm UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/9 "2025-09-05T16:33:22Z")

</div>

Thanks very much Alex I got it working.

---

<div class="post-metadata">

**Author:** ![sean](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sean](https://community.mindstudio.ai/u/sean)\
**Post date:** [September 5, 2025, 4:42pm UTC](https://community.mindstudio.ai/t/http-request-block-failing-with-401-unauthorized-error/1585/10 "2025-09-05T16:42:37Z")

</div>

@ramelton Glad to hear you got in working! Can you briefly share what the issue was and how you fixed it? Just for anyone else who might be browsing and running into the same sort of issue!
