Invoke-RestMethod Accept Header not working properly in Azure

%3CLINGO-SUB%20id%3D%22lingo-sub-2385756%22%20slang%3D%22en-US%22%3EInvoke-RestMethod%20Accept%20Header%20not%20working%20properly%20in%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2385756%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20consuming%20an%20API%20that%20returns%20different%20input%20depending%20on%20the%20Accept%20header.%3C%2FP%3E%3CP%3E'Accept'%20%3D%20'application%2Fjson'%20(%20or%20empty%20%2F%20default)%20returns%20JSON%3CBR%20%2F%3E'Accept'%20%3D%20'application%2Fhujson'%20returns%20Human%20Readable%20JSON%20which%20I%20need%20in%20this%20case%3C%2FP%3E%3CP%3EUsing%20PowerShell%20on%20my%20desktop%2C%20this%20works%20as%20expected.%3C%2FP%3E%3CP%3EThe%20exact%20same%20code%20in%20Azure%20CLI%20or%20PS-Core%20function%20app%20always%20returns%20JSON%20no%20matter%20what%20the%20Accept%20header%20specifies.%3C%2FP%3E%3CP%3EAny%20idea%20how%20to%20go%20about%20resolving%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2385756%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Automation%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

I am consuming an API that returns different input depending on the Accept header.

'Accept' = 'application/json' ( or empty / default) returns JSON
'Accept' = 'application/hujson' returns Human Readable JSON which I need in this case

Using PowerShell on my desktop, this works as expected.

The exact same code in Azure CLI or PS-Core function app always returns JSON no matter what the Accept header specifies.

Any idea how to go about resolving this?

 

 

0 Replies