Mastercard / terraform-provider-restapi

A terraform provider to manage objects in a RESTful API
Other
808 stars 217 forks source link

Support for different Content-Type / Headers for each method #246

Open owitplat opened 11 months ago

owitplat commented 11 months ago

Hello,

Thanks very much for providing this excellent module.

Our use case is to consume an API that requires a different Content-Type for each of GET , DELETE, POST and PATCH.

Specifically, we need Content-Type = application/json for GET Content-Type = application/vnd.api+json for POST and PATCH No Content-Type for DELETE

We've not been able to come up with a way to set the Content-Type based on method.

We currently set Content-Type with headers = { "Authorization" = "ApiKey ${var.apikey}" "Content-Type" = "${var.content_type}", }

which is then used for all actions.

We can't create a plan unless we use -refresh=false to skip the GET call since the API is expecting application/json. Using a JSON API type returns Error: unexpected response code '415': {"message": "Unsupported Media Type"}

I'm not sure if that's a common use case.. the API we are calling is a SaaS product that we can't influence.

We're using terraform 1.6.1 ; restapi v1.18.2

thanks.