Skip to content

[BUG] Proxy forces JSON body even when Content-Type is application/x-www-form-urlencoded #10557

@dmatviichuk

Description

@dmatviichuk

Bug Description

When sending a proxy request with Content-Type: application/x-www-form-urlencoded, Hyperswitch always serializes the request_body as JSON before forwarding it to the destination connector. This causes downstream APIs expecting form-encoded payloads to fail.

This was observed while integrating with Athena’s collectpayment endpoint, which strictly requires form-url-encoded body format.

Expected Behavior

Hyperswitch proxy service should detect the header Content-Type: application/x-www-form-urlencoded and forward the request_body encoded as form-url-encoded, not JSON.

Example expected format:
billingzip=85000&expirationyearyyyy=2030&departmentid=1&...

Actual Behavior

Even when the incoming proxy request contains "Content-Type": "application/x-www-form-urlencoded" the body is still sent as JSON

{
  "billingzip": "85000",
  "expirationyearyyyy": "2030",
  "departmentid": "1"
}

Steps To Reproduce

Create a proxy request with the following payload:

{
  "destination_url": "https://api.preview.platform.example.com/v1/1/user/1/collectpayment",
  "headers": {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  "method": "POST",
  "request_body": {
    "billingzip": "85000",
    "expirationyearyyyy": "2030",
    "amount": "20.00"
  }
}

Observe that the outgoing HTTP request body is JSON instead of form-encoded

Context For The Bug

No response

Environment

Are you using hyperswitch hosted version? No
If yes, please provide the value of the x-request-id response header to help us debug your issue.

If not (or if building/running locally), please provide the following details:

  1. Operating System or Linux distribution:
  2. Rust version (output of rustc --version): ``
  3. App version (output of cargo r --features vergen -- --version): v1.117.0 with VERSION_FEATURE_SET v2

Have you spent some time checking if this bug has been raised before?

  • I checked and didn't find a similar issue

Have you read the Contributing Guidelines?

Are you willing to submit a PR?

Yes, I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: BugS-awaiting-triageStatus: New issues that have not been assessed yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions