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

Add a way to handle apis that return the id directly not in a JSON

Open landorg opened this issue 3 years ago • 2 comments

Hi,

I got an API that I'd want to handle with this provider that returns the id directly like that:

[I] ➜ curl --request POST \
  --url https://api.example.org/v1/something \
  --header "Authorization: Bearer $dc_token" \
  --header 'Content-Type: application/json' \
  --data '{ "some": "thing" }'

1f9a92b4-f3c1-4dcb-a44c-87ab708b24d2

I think this is currently not possible to handle.

landorg avatar Apr 15 '22 14:04 landorg

Hi, @landorg - you are correct. Unfortunately this is not possible with the provider as it exists today because the expectation is that some form of write operation will return the whole object (create or update) so internal data structures can be updated.

By chance, would this API support an immediate GET after the creation like so?

curl https://api.example.org/v1/something/1f9a92b4-f3c1-4dcb-a44c-87ab708b24d2

If so... a feature enhancement may be possible to help avoid this issue. I have come across another API that operates this way, so it may be a worthwhile addition.

DRuggeri avatar Apr 20 '22 16:04 DRuggeri

Hi and thanks for your quick reply :) Yes an immediate get is possible with that api.

landorg avatar Apr 21 '22 14:04 landorg