"ERROR: Unsupported Media Type" when trying to use az rest
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
Getting subj error when calling put command. Went through other issues. Tried single line, backslash encoded, bash/PS. Always the same. I know people who can run this without issues. What could be misconfigured in my environment?
### Related command
az rest --uri /subscriptions/$subId/resourceGroups/$rg/providers/Microsoft.Web/sites/$appname/config/authsettings?api-version=2020-09-01 --method put --body auth4.json
### Errors
Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}})
### Issue script & Debug output
PS C:\Users\xxx> az rest --uri /subscriptions/9f64276cxxx/resourceGroups/xxx/providers/Microsoft.Web/sites/xxx/config/authsettings?api-version=2020-09-01 --method put --body auth4.json --debug
cli.knack.cli: Command arguments: ['rest', '--uri', '/subscriptions/9f64276cxxx/resourceGroups/xxx/providers/Microsoft.Web/sites/xxx/config/authsettings?api-version=2020-09-01', '--method', 'put', '--body', 'auth4.json', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'rest': ['azure.cli.command_modules.util']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Loaded command modules in parallel:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: util 0.003 3 7
cli.azure.cli.core: Total (1) 0.004 3 7
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 3 groups, 7 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : rest
cli.azure.cli.core: Command table: rest
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\xxx\.azure\commands\2026-03-15.14-01-52.rest.32168.log'.
az_command_data_logger: command args: rest --uri {} --method {} --body {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x0000019D1CA6EDE0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x0000019D1CA9D120>, .add_cache_arguments at 0x0000019D1CA9D300>, .update_breaking_change_info at 0x0000019D1CA9D3A0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x0000019D1CA9D1C0>]
cli.azure.cli.core.util: malformed node or string on line 1:
cli.azure.cli.core.util: Found subscription ID 9f64276c-749d-40d4-948b-96c6ec4c3102 in the URL https://management.azure.com/subscriptions/9f64276c-749d-40d4-948b-96c6ec4c3102/resourceGroups/xxx/providers/Microsoft.Web/sites/xxx/config/authsettings?api-version=2020-09-01
cli.azure.cli.core.util: Retrieving token for resource https://management.core.windows.net/, subscription 9f64276cxxx
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\\Users\\xxx\\.azure\\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\xxx\.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/b0f12464-xxx
msal.authority: openid_config("https://login.microsoftonline.com/b0f12464-xxx/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/b0f12464-121f-4db3-82de-1b9f93eb34e6/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic', 'self_signed_tls_client_auth'], 'jwks_uri': 'https://login.microsoftonline.com/b0f12464-xxx/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/b0f12464-121f-4db3-82de-1b9f93eb34e6/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/b0f12464-121f-4db3-82de-1b9f93eb34e6/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/b0f12464xxx/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/b0f12464-121f-4db3-82de-1b9f93eb34e6/kerberos', 'mtls_endpoint_aliases': {'token_endpoint': 'https://mtlsauth.microsoft.com/b0f12464-xxx/oauth2/v2.0/token'}, 'tls_client_certificate_bound_access_tokens': True, 'tenant_region_scope': 'NA', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? True
cli.azure.cli.core.auth.msal_credentials: UserCredential.acquire_token: scopes=['https://management.core.windows.net//.default'], claims_challenge=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 0bfb996c-9d66-4a10-a8d6-0911e2ba3161
cli.azure.cli.core.util: Request URL: 'https://management.azure.com/subscriptions/9f64276c-xxx/resourceGroups/xxx/providers/Microsoft.Web/sites/xxx/config/authsettings?api-version=2020-09-01'
cli.azure.cli.core.util: Request method: 'PUT'
cli.azure.cli.core.util: Request headers:
cli.azure.cli.core.util: 'User-Agent': 'python/3.13.11 (Windows-11-10.0.26100-SP0) AZURECLI/2.84.0 (MSI)'
cli.azure.cli.core.util: 'Accept-Encoding': 'gzip, deflate'
cli.azure.cli.core.util: 'Accept': '*/*'
cli.azure.cli.core.util: 'Connection': 'keep-alive'
cli.azure.cli.core.util: 'x-ms-client-request-id': '1df6e966-853c-4539-bed9-e543cf5f49d0'
cli.azure.cli.core.util: 'CommandName': 'rest'
cli.azure.cli.core.util: 'ParameterSetName': '--uri --method --body --debug'
cli.azure.cli.core.util: 'Authorization': 'Bearer eyJ0eXAiOiJKV...'
cli.azure.cli.core.util: 'Content-Length': '10'
cli.azure.cli.core.util: Request body:
cli.azure.cli.core.util: auth4.json
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/9f64276c-xxx/resourceGroups/xxx/providers/Microsoft.Web/sites/xxx/config/authsettings?api-version=2020-09-01 HTTP/1.1" 415 141
cli.azure.cli.core.util: Response status: 415
cli.azure.cli.core.util: Response headers:
cli.azure.cli.core.util: 'Cache-Control': 'no-cache'
cli.azure.cli.core.util: 'Pragma': 'no-cache'
cli.azure.cli.core.util: 'Content-Length': '141'
cli.azure.cli.core.util: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.util: 'Expires': '-1'
cli.azure.cli.core.util: 'x-ms-failure-cause': 'gateway'
cli.azure.cli.core.util: 'x-ms-request-id': '72da21e0-77aa-4e3c-8cd1-f45816200914'
cli.azure.cli.core.util: 'x-ms-correlation-request-id': '72da21e0-77aa-4e3c-8cd1-f45816200914'
cli.azure.cli.core.util: 'x-ms-routing-request-id': 'CENTRALUS:20260315T210153Z:72da21e0-77aa-4e3c-8cd1-f45816200914'
cli.azure.cli.core.util: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.util: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.util: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.util: 'X-MSEdge-Ref': 'Ref A: 897BAE7A8DFB4E2DBE399566BF6851FC Ref B: CO6AA3150220021 Ref C: 2026-03-15T21:01:53Z'
cli.azure.cli.core.util: 'Date': 'Sun, 15 Mar 2026 21:01:52 GMT'
cli.azure.cli.core.util: Response content:
cli.azure.cli.core.util: {"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 682, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 812, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 781, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 24, in rest_call
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 1096, in send_raw_request
azure.cli.core.azclierror.HTTPError: Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}})
cli.azure.cli.core.azclierror: Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}})
az_command_data_logger: Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}})
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.256 seconds (init: 0.335, invoke: 0.920)
cli.azure.cli.core.decorators: Suppress exception:
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/__main__.py", line 53, in
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/__main__.py", line 46, in
SystemExit: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/decorators.py", line 79, in _wrapped_func
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 131, in generate_payload
File "json\__init__.py", line 242, in dumps
File "json\encoder.py", line 202, in encode
File "json\encoder.py", line 263, in iterencode
File "json\encoder.py", line 182, in default
TypeError: Object of type HTTPError is not JSON serializable
telemetry.main: Split cli events and extra events failure: the JSON object must be str, bytes or bytearray, not NoneType
### Expected behavior
Expected behavior is that the Content-Type header is set by default to application/json as per the az rest documentation here:
https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az-rest
Then that the HTTP 2.0 Proxy flag is set correctly and that the response from az rest returns the updated state of the resource rather than an error.
### Environment Summary
azure-cli 2.84.0
core 2.84.0
telemetry 1.1.0
Extensions:
authV2 0.1.1
Dependencies:
msal 1.35.0b1
azure-mgmt-resource 24.0.0
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\xxx\.azure'
Extensions directory 'C:\Users\xxx\.azure\cliextensions'
Python (Windows) 3.13.11 (tags/v3.13.11:6278944, Dec 5 2025, 16:26:58) [MSC v.1944 64 bit (AMD64)]
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.