I am trying to make a RestAPI call to a service which specifies in it's documentation the following:
An Integration Server can respond in XML and JSON formats. Use one of the following accept headers in your requests:
- accept: application/json, /.
- accept: application/xml, /
If the accept header does not include application/xml, application/json or /, the integration server will respond with a "406 method not acceptable" status code.
My powershell code looks like this
Invoke-RestMethod -URI https://URL/ticket -Credential $cred -Method Get -Headers @{"Accept"="application/xml"}
But I get the following error relating to the header:
Invoke-RestMethod : This header must be modified using the appropriate property or method.
Parameter name: name
Can someone assist me with understanding why powershell wont let me specify the Accept header? Or is there another method I'm missing here?
Thanks