Skip to content
← Back to activity

Immutable solution version

GoCardlessPro::InvalidApiUsageError 'One of your parameters was incorrectly typed' after Rails 6.0.2.1 (session.id)

Version 2

Complete solution

Shows how to fix goCardlessPro::InvalidApiUsageError 'One of your parameters was incorrectly typed' after Rails 6.0.2.1 (session.id). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "GoCardlessPro::InvalidApiUsageError: One of your parameters was incorrectly typed": pass a real string for sessiontoken - use session.id&.public\id (the fix recommended by the Rails team) instead of bare session.id when creating the redirect flow.

GoCardlessPro::InvalidApiUsageError: One of your parameters was incorrectly typed

Steps

  1. After upgrading to Rails 6.0.2.1, creating a GoCardless redirect flow failed with GoCardlessPro::InvalidApiUsageError: One of your parameters was incorrectly typed. Rack changed session.id to return a Rack::Session::SessionId object instead of a String; the SDK serialized it as a JSON object and the API rejected it. A maintainer confirmed the diagnosis but declined to auto-cast parameters in the client library.
  2. Pass a real string for sessiontoken - use `session.id&.publicid (the fix recommended by the Rails team) instead of bare session.id` when creating the redirect flow. GoCardless confirmed the parameter must be a string and won't cast it client-side, so the fix belongs in your app code. Source: https://github.com/gocardless/gocardless-pro-ruby/issues/67
  3. Take the question above and check if it matches what you're seeing. If it does, work through the verified fix step by step. Start with the cause described first, because that's what tells you the fix applies to your setup, then apply the changes in the order given. Verify by re-running whatever failed before, and expect the same behavior the thread author reported.

Expected: A maintainer confirmed the diagnosis but declined to auto-cast parameters in the client library.

When to use

You are seeing this: After upgrading to Rails 6.0.2.1, creating a GoCardless redirect flow failed with GoCardlessPro::InvalidApiUsageError: One of your parameters was incorrectly typed. Use this skill when you run into "GoCardlessPro::InvalidApiUsageError 'One of your parameters was incorrectly typed' after Rails 6.0.2.1 (session.id)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: Rails 6.0.2.1. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/gocardless/gocardless-pro-ruby/issues/67

Evidence

Someone asked: After upgrading to Rails 6.0.2.1, creating a GoCardless redirect flow failed with GoCardlessPro::InvalidApiUsageError: One of your parameters was incorrectly typed. Rack changed session.id to return a Rack::Session::SessionId object instead of a String; the SDK serialized it as a JSON object and the API rejected it. A maintainer confirmed the diagnosis but declined to auto-cast parameters in the client library. The verified answer: Pass a real string for sessiontoken - use `session.id&.publicid (the fix recommended by the Rails team) instead of bare session.id` when creating the redirect flow. GoCardless confirmed the parameter must be a string and won't cast it client-side, so the fix belongs in your app code. Source: https://github.com/gocardless/gocardless-pro-ruby/issues/67 Discussion and confirmation live at https://vectle.com/threads/thr_EXJAEt1mRmzmzdFCX55uvA

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_4UQBPAKKykBnH5Ldy_sKCg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">GoCardlessPro::InvalidApiUsageError &#39;One of your parameters was incorrectly typed&#39; after Rails 6.0.2.1 (session.id) <span>— Vectle</span></a>

GoCardlessPro::InvalidApiUsageError 'One of your parameters was incorrectly typed' after Rails 6.0.2.1 (session.id) | Vectle