Skip to content

Verify PUT and PATCH API requests include Content-Type header#194

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-put-patch-call-issue
Closed

Verify PUT and PATCH API requests include Content-Type header#194
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-put-patch-call-issue

Conversation

Copilot AI commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Issue reported that PUT and PATCH requests were failing with 415 Unsupported Media Type errors, claiming the tools lacked header support. Investigation revealed the issue was already resolved in PR #193 (v1.0.11).

Current State

Both playwright_put and playwright_patch already support:

  • Automatic Content-Type: application/json header injection
  • Custom headers via headers parameter
  • Bearer token authentication via token parameter

Implementation (src/tools/api/requests.ts):

const response = await apiContext.put(args.url, {
  data: parseJsonSafely(args.value),
  headers: buildHeaders(args.token, args.headers, true)  // Content-Type added
});

Changes

  • Added integration tests (src/__tests__/tools/api/put-patch-integration.test.ts)
    • Verifies Content-Type header is automatically included
    • Tests custom headers merging
    • Tests Bearer token authentication
    • Covers the exact FakeRestAPI scenario from the issue report

Usage

// Content-Type automatically included - no more 415 errors
await playwright_put({
  url: 'https://fakerestapi.azurewebsites.net/api/v1/Activities/1',
  value: JSON.stringify({ id: 1, title: 'Updated' })
});

// With custom headers and auth
await playwright_put({
  url: 'https://api.example.com/resource/1',
  value: '{"name":"test"}',
  token: 'bearer-token',
  headers: { 'Accept': 'application/json' }
});

Test Results: 159/159 passing (150 existing + 9 new)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fakerestapi.azurewebsites.net
    • Triggering command: `/usr/local/bin/node node -e
      const { request } = require('playwright');

(async () => {
const apiContext = await request.newContext({
baseURL: 'REDACTED'
});

// Test PUT request with Content-Type header
console.log('Testing PUT request...');` (dns block)

  • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/mcp-playwright/mcp-playwright/node_modules/jest-worker/build/workers/processChild.js (dns block)
  • jsonplaceholder.typicode.com
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/mcp-playwright/mcp-playwright/node_modules/jest-worker/build/workers/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Not able to perform Put and Patch call while performing API testing using MCP Server.</issue_title>
<issue_description>Steps to Reproduce -
1- Provide prompt to perform Update API Call (More details are in this link - https://fakerestapi.azurewebsites.net/index.html )
2 - Provide valid body with put call -
{
"id": 1,
"title": "string",
"dueDate": "2025-08-18T20:48:58.627Z",
"completed": true
}
3- Send the Prompt in Copilot or Claude or any other AI Assistant.

Issue - In Postman call is successful and it is giving response but when we are using MCP Server it is not able to perform API Put and Patch API calls. , I have tried same with other website API calls also.

Adding Claude / Copilot response -
The PUT request returned a 415 Unsupported Media Type error. This suggests the API requires specific headers that aren't being set by the playwright_put function.

Unfortunately, the current Playwright EA MCP Server tools don't provide a way to send a PUT request with custom headers like the accept and Content-Type headers specified in your curl command. The playwright_put function only accepts a URL and body value, but doesn't have a headers parameter like the playwright_post function does.</issue_description>

<agent_instructions>Check why the issue is happening, this should not happen for PUT or PATCH, check the latest code changes we made and see the issue will still occur </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 11, 2025 08:41
Co-authored-by: executeautomation <10337030+executeautomation@users.noreply.github.com>
Co-authored-by: executeautomation <10337030+executeautomation@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with PUT and PATCH calls on MCP Server Verify PUT and PATCH API requests include Content-Type header Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to perform Put and Patch call while performing API testing using MCP Server.

2 participants