Invoke-RestMethod – how to pass “ETag does not represent the latest state of the resource.”

Question:

Question

How to pass the exception having the following message?

Invoke-RestMethod : {“Message”:”ETag does not represent the latest state of the resource.”}

Seeing the reference, I think “passing If-Match: "*" header” should be a key, but don’t know how to do this.

Note: when updating or deleting a file, ETag behavior will apply. You can pass a If-Match: “*” header to disable the ETag check.

To do

  • Putting the file “sample1.html” to specific directory of the website
  • In a Runbook of Azure Automation account

Code


Output

Answer:

As hinted in the comments, the -Headers parameter accept a hashtable with multiple keys, like so:


and then:

Source:

Invoke-RestMethod – how to pass “ETag does not represent the latest state of the resource.” by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply