conekta / conekta-ruby

Ruby Bindings for Conekta
https://www.conekta.com
MIT License
31 stars 28 forks source link

Empty response... A JSON text must at least contain two octets! #87

Closed betterm closed 6 years ago

betterm commented 6 years ago

Hi, we have some problems during Oxxo Conekta order create, it happens only sometimes it seems. Here our request:

request_params = { "line_items": [ { "name": "Shipment ECOEXPRESS", "unit_price": 7334, "quantity": 1 } ], "shipping_lines": [ { "amount": 0, "carrier": "Redpack", "tracking_number": "U5UT96B1" } ], "currency": "MXN", "customer_info": { "name": "Client Name", "email": "client@email.com", "phone": "1122334455" }, "shipping_contact": { "phone": "1122334455", "receiver": "Receiver Name", "address": { "street1": "Kepler 195", "city": "Mexico", "state": "DF", "country": "MX", "postal_code": "11590", "residential": true } }, "charges": [ { "payment_method": { "type": "oxxo_cash" } } ], "metadata": { "enviaya_payment_id": 89854, "target_model": "Shipment", "target_id": 1359361, "model_amount": 69.95, "order_id": 81717 } }

conekta_order = Conekta::Order.create(request_params)

Then we get this error:

A JSON text must at least contain two octets! "/home/ubuntu/apps/enviaya/shared/bundle/ruby/2.4.0/gems/json-1.8.6/lib/json/common.rb:155:in initialize'", "/home/ubuntu/apps/enviaya/shared/bundle/ruby/2.4.0/gems/json-1.8.6/lib/json/common.rb:155:innew'", "/home/ubuntu/apps/enviaya/shared/bundle/ruby/2.4.0/gems/json-1.8.6/lib/json/common.rb:155:in parse'", "/home/ubuntu/apps/enviaya/shared/bundle/ruby/2.4.0/bundler/gems/conekta-ruby-f6028bc9800b/lib/conekta/requestor.rb:33:inrequest'", "/home/ubuntu/apps/enviaya/shared/bundle/ruby/2.4.0/bundler/gems/conekta-ruby-f6028bc9800b/lib/conekta/operations/create.rb:7:in create'"

So it seems response body is empty string, and we receive the error in JSON parse...

lu1s commented 6 years ago

Hi @betterm. Did you try with a JSON without keys as strings? (use symbols as regular).

betterm commented 6 years ago

@lu1s of course, currently we are using symbol keys, but it doesn't matter which keys I put, it works in both ways

lu1s commented 6 years ago

Can you share more context on how is that part of the code implemented in your snippet?

betterm commented 6 years ago

Well, I shared the whole part where the error happens, there just request hash, the order create request line it self, and then rescue, with the error message I also shared here. What else can be useful?

edenriquez commented 6 years ago

@betterm is this error still happening ? i remember that was an error during some deployment we done, our balancer some times returns empty response if it was not able to reach api response in that specific date range