terraform-provider-azapi icon indicating copy to clipboard operation
terraform-provider-azapi copied to clipboard

Data source azapi_resource_action does not handle responses that are not json.

Open AustinSmart opened this issue 3 years ago • 1 comments

When using data source azapi_resource_action with an action that returns Content-Type: text/plain, the resource errors with the following error as it is expecting a JSON response:

unmarshalling type *interface {}: invalid character '<first char of response body>' looking for beginning of value

My use case is retrieving the output of an automation account job and saving the entire body as an output.

data "azapi_resource_action" "job_output" {
  type = "Microsoft.Automation/automationAccounts/jobs@2019-06-01"
  resource_id = <job resource id>
  action = "output"
  method = "GET"
}

This results in an API call that returns plain text

AustinSmart avatar Aug 17 '22 19:08 AustinSmart

Hi @AustinSmart ,

Thank you for taking time to report this issue!

Yes, it doesn't work with text/plain content type, I'll work on supporting it.

ms-henglu avatar Aug 18 '22 01:08 ms-henglu