HTTP API Gateway - HTTP URI Integration fails when query contains spaces

1

I have an HTTP API Gateway with a "search" route that calls an external API via the HTTP URI integration type. I want to map the query string parameter "song" in my API to "q" in the external API, with a static prefix added. For example, GET /search?song=Yesterday should map to https://external-api/search?q=The+Beatles+-+Yesterday.

This works in my example above, but breaks if the original query contains a space (e.g., searching for Hey Jude instead of Yesterday).

The only workaround I have found is to URL encode the original query twice (e.g. calling my API with GET /search?song=Hey%2520Jude).

My current parameter mapping is as follows:

Parameter to modifyModification typeValue
querystring.qOverwritethe%20beatles%20-%20$request.querystring.song

I've tried the following to no avail:

  • + instead of %20
  • Removing the prefix and just mapping q to $request.querystring.song
  • Adding brackets (e.g., ${request.querystring.song})

I would like to be able to map GET /search?song=Hey%20Jude to https://external-api/search?q=The%20Beatles%20-%20Hey%20Jude without having to double-encode my input (as this would be annoying for people calling my API).

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인