question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az rest command working on v2.0.76 but not v2.1.0

See original GitHub issue

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug I used the az rest --method put --uri https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Web/sites/{app_name}/config/web?api-version=2019-08-01 --body '{\"properties\":{\"healthCheckPath\":\"/version\"}}' with v2.0.76, it worked fine. But when I tried the same command with v2.1.0, it gave this error: ERROR: Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '<null>' is not supported. Only 'application/json' is supported."}})

Then, I changed the command to az rest --method put --uri https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.Web/sites/$APP_NAME/config/web?api-version=2019-08-01 --body '{\"properties\":{\"healthCheckPath\":\"/actuator/health\"}}' --headers '{\"Content-Type\":\"application/json\"}', The difference is to add application/json content type header. But I got another error: ERROR: not enough values to unpack (expected 2, got 1).

I also changed the format of header to --headers "Content-Type=application/json" as per documentation(https://docs.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az-rest). But I got another error: ERROR: Bad Request({"error":{"code":"InvalidRequestContent","message":"The request content was invalid and could not be deserialized: 'Invalid property identifier character: \\. Path '', line 1, position 1.'."}}). I verified this --headers "Content-Type=application/json" with v2.2.0, it works. Not sure what happens to v2.1.0.

I didn’t know why the same command working for v2.0.76, but not working for v2.1.0. Can someone figure it out? Many thanks in advance.

To Reproduce Please see above

Expected behavior The same command should work for both versions.

Environment summary

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Splaxicommented, Nov 28, 2020

For anyone find this when searching for:

Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '<null>' is not supported. Only 'application/json' is supported."}})

It is most likely that you have 2 issues: Your json needs to be a single line json string, escaped. I had a multi line json in a variable in PowerShell, and when converting it to a single line and escaping the " (double qoute) to \" (slash double quote) the error went away.

1reaction
jiaslicommented, May 9, 2022

For PowerShell quoting issue, please see https://github.com/Azure/azure-cli/issues/15529.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AZ REST Command Forbidden - Stack Overflow
I used the GET method to see my Web-redirectUrl to make sure whether it is updated or not. az rest --method GET --uri ......
Read more >
Release notes & updates – Azure CLI - Microsoft Learn
Learn about the latest Azure Command-Line Interface (CLI) release notes and updates for both the current and beta versions of the CLI.
Read more >
TOXICOLOGICAL PROFILE FOR NAPHTHALENE, 1 ...
Chapter 2: Relevance to Public Health: The Relevance to Public Health Section evaluates, interprets, and assesses the significance of toxicity data to human ......
Read more >
Azure CLI: Call Azure REST API Directly - Build5Nines
There are 2 methods that can be used to make Azure REST API calls from ... If no authentication argument is passed to...
Read more >
Getting started with Azure CLI 2.0 - SQLShack
This tool gives us the ability to issue commands right from the windows command prompt and deal with the Azure resources. Since this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found