Open Nevemoire opened 2 months ago
Hi @Nevemoire, Please provide additional details such as -
OpenStack
's API with Hasura? (Actions ?) Hi @rakeshkky. Yes, all the communication with OpenStack is handled via Hasura Actions.
For POST
, GET
and DELETE
calls everything works fine as far as I pass OpenStack's token via X-Auth-Token
header. The problem appears when I'm trying to make a PATCH
request as it's needed to pass a custom Content-Type
header as I've mentioned above.
When I'm testing update Action via Hasura's API explorer, here is what I'm passing:
"headers": [ { "name": "Content-Type", "value": "application/openstack-images-v2.1-json-patch" }, { "name": "X-Forwarded-Host", "value": "xxx:8080" }, { "name": "X-Forwarded-User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 YaBrowser/24.7.0.0 Safari/537.36" }, { "name": "X-Forwarded-Origin", "value": "http://xxx:8080" }, { "name": "x-request-id", "value": "3b9086ee-4a6f-4ede-af0b-0213e276a630" }, { "name": "X-Auth-Token", "value": "xxx" } ],
but in transformed request Content-Type
equals application/json
, therefore I receive 415 status error from OpenStack.
Sorry if my explanation is not clear
Thank you for the information. Have you checked out Request Transformation in Actions? It has a way to set the Content-Type
header value.
Ref: Rest Connectors
@rakeshkky gotcha. Now I'm trying to manually import metadata where I specify request_transform
as:
"request_transform": { "method": "PATCH", "query_params": {}, "template_engine": "Kriti", "url": "{{$base_url}}/{{escapeUri($body.input.id)}}", "content_type": "application/openstack-images-v2.1-json-patch", "version": 1 },
, but after importing it removes a content_type
field. Can you please explain what am I doing wrong?
Full action:
{ "name": "updateImage", "definition": { "handler": "http://ip:port/v2/images", "output_type": "UpdatedImage", "forward_client_headers": true, "arguments": [ { "name": "id", "type": "String!" }, { "name": "name", "type": "String" }, { "name": "size", "type": "Int" } ], "request_transform": { "method": "PATCH", "query_params": {}, "template_engine": "Kriti", "url": "{{$base_url}}/{{escapeUri($body.input.id)}}", "content_type": "application/openstack-images-v2.1-json-patch", "version": 1 }, "type": "mutation", "kind": "synchronous" } }
Is your proposal related to a problem? Yes
I'm using Hasura to communicate with OpenStack's API. Trying to make a change to existing image instance I've encountered a problem that I can't change
Content-Type
header to my value, it's always transformed automatically toapplication/json
. Accordingly to an OpenStack's API Docs it's value must beapplication/openstack-images-v2.1-json-patch
, otherwise it will return 415 status error.Describe the solution you'd like
The best solution would be to have an opportunity to override default values if needed.