Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
owitplat opened this issue Oct 16, 2023 · 0 comments
Open

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

owitplat opened this issue Oct 16, 2023 · 0 comments

Comments

@owitplat
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant