microsoft/semantic-kernel · error · Exception
Neither of the media types of {operation_id} is supported.
Error message
Neither of the media types of {operation_id} is supported. What it means
`_create_rest_api_operation_payload` picks the first media type in the request body `content` that appears in `OpenApiParser.SUPPORTED_MEDIA_TYPES`; if none match, it raises a bare `Exception` naming the operation. Only the supported media types can be turned into a payload property tree.
Source
Thrown at python/semantic_kernel/connectors/openapi_plugin/openapi_parser.py:143
)
result.append(property)
return result
def _create_rest_api_operation_payload(
self, operation_id: str, request_body: dict[str, Any]
) -> RestApiPayload | None:
if request_body is None or request_body.get("content") is None:
return None
content = request_body.get("content")
if content is None:
return None
media_type = next((mt for mt in OpenApiParser.SUPPORTED_MEDIA_TYPES if mt in content), None)
if media_type is None:
raise Exception(f"Neither of the media types of {operation_id} is supported.")
media_type_metadata = content[media_type]
payload_properties = self._get_payload_properties(
operation_id, media_type_metadata["schema"], media_type_metadata["schema"].get("required", set())
)
return RestApiPayload(
media_type,
payload_properties,
request_body.get("description"),
schema=media_type_metadata.get("schema", None),
)
def _create_response(self, responses: dict[str, Any]) -> Generator[tuple[str, RestApiExpectedResponse], None, None]:
for response_key, response_value in responses.items():
media_type = next(
(mt for mt in OpenApiParser.SUPPORTED_MEDIA_TYPES if mt in response_value.get("content", {})), None
)
if media_type is not None:View on GitHub (pinned to c028a0c7dc)
Solutions
- Add an `application/json` media type entry to the request body for that operation.
- If the API genuinely only supports XML/multipart, exclude that operation from registration via include/exclude filters.
- Send the body as a raw string argument (set `payload_argument_name`) if you need a non-JSON body, after excluding dynamic payload building.
- Pre-process the spec to add a JSON variant before loading.
Example fix
# before
requestBody:
content:
application/xml: { schema: { ... } } # raises 1492
# after
requestBody:
content:
application/json: { schema: { ... } } Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"application/json"} # mirror OpenApiParser.SUPPORTED_MEDIA_TYPES
def unsupported_body_ops(spec) -> list[str]:
bad = []
for path, methods in spec.get("paths", {}).items():
for method, d in methods.items():
content = (d.get("requestBody") or {}).get("content", {})
if content and not (set(content) & SUPPORTED):
bad.append(f"{method} {path}: {list(content)}")
return bad
problems = unsupported_body_ops(spec)
assert not problems, problems Type guard
def has_supported_media_type(op_details) -> bool:
content = (op_details.get("requestBody") or {}).get("content", {})
return bool(set(content) & {"application/json"}) Try / catch
try:
kernel.add_openapi_plugin(plugin_name="x", openapi_parsed_spec=spec)
except Exception as e: # bare Exception per source
if "Neither of the media types" in str(e):
# add application/json to the op, or exclude it, then retry
raise
raise Prevention
- Add `application/json` to request bodies you want registered.
- Exclude binary/multipart/XML endpoints via operation filters.
- Lint specs to flag unsupported-media-type bodies.
- Pre-process vendor specs to add a JSON variant.
When it happens
Trigger: An operation whose `requestBody.content` lists only unsupported media types (e.g. `application/xml`, `multipart/form-data`, `application/octet-stream`, or a custom vendor type) and none of the supported ones (typically `application/json`).
Common situations: XML-only or multipart APIs; specs that default to a vendor media type; binary-upload endpoints modeled via request body; specs imported from a SOAP/REST converter.
Related errors
- Error parsing OpenAPI document: {openapi_document_path}
- Max level {OpenApiParser.PAYLOAD_PROPERTIES_HIERARCHY_MAX_DE
- This `RestApiParameter` instance is frozen and cannot be mod
- This `RestApiPayload` instance is frozen and cannot be modif
- This instance is frozen and cannot be modified.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/1a556cab1a814d59.
Report an issue: GitHub.