ShopifyAPI ApplicationCharge Bad Request

Topic summary

Intermittent failure creating an ApplicationCharge (one‑time app fee) via Shopify Admin REST API 2023-07 using the Ruby ShopifyAPI. Code uses a temporary session, instantiates ApplicationCharge, sets name/price/return_url, and calls save!.

Observed error: charge.save! sometimes raises JSON::ParserError: “Empty input … in 'Bad Request” — suggesting an HTTP 400 with an empty/invalid JSON body that the client attempts to parse.

Context/assumptions: Locally it works. Reporter believes common causes don’t fit: price < $0.5 would return a 500; invalid access token or wrong shop domain likely wouldn’t result in a 400. API docs indicate the usage pattern appears correct.

Key terms: ApplicationCharge = one‑time billing charge; JSON::ParserError = Ruby error when parsing invalid/empty JSON response.

Artifacts central to understanding: the provided Ruby code snippet.

Outcome/status: No fix or definitive cause identified; assistance requested. Discussion remains open.

Summarized with AI on January 10. AI used: gpt-5.

Hi all! Recently we’ve seen a few errors with our app when attempting to use the ShopifyAPI on version

2023-07 to make an Application Charge. We are running

ShopifyAPI::Auth::Session.temp(shop: shop_domain, access_token: access_token) do
    charge = ShopifyAPI::ApplicationCharge.new
    charge.name = name
    charge.price = price
    charge.return_url = return_url
    charge.save!
    charge
end

Sometimes the charge.save! throws

JSON::ParserError
Empty input (after ) at line 1, column 1 [parse.c:1081] in 'Bad Request

To me this looks like the response we’re getting is a Bad Request error, however I have no idea how that could be generated. If the price were under $0.5 we’d be getting a 500, if the access token no longer worked or the domain were wrong I don’t think we’d get a Bad Request response either. Would love some help on this, since everything works locally and the docs make me think we’re not doing anything crazy.