Code Monkey home page Code Monkey logo

Comments (7)

godfat avatar godfat commented on August 12, 2024

Anymore information? Like the full backtrace, the original responses, etc.

from rest-core.

AshwiniDoddamaniFluke avatar AshwiniDoddamaniFluke commented on August 12, 2024

`Requested GET https: //streaming.preprod.connect.fluke.com/iot-service/history/reports/download/b9498f13-62cf-44ba-9a1e-1eb2b4444d22?deviceType=fc3540&frequency=TWELVE_HOUR&sessionStartTime=1499763413506&from=1502877600000&reportType=xlsx&requesterTimeZone=GMT%2B0530&app_platform=website&app_vers=270

RestBuilder::Promise: ERROR: invalid byte sequence in UTF - 8

from["/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/util/json.rb:75:in sub'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/util/json.rb:75:in strip_bom'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/util/json.rb:66:in normalize'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/json_response.rb:34:in process'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/json_response.rb:26:in block in call'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/common_logger.rb:13:in block in call'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/cache.rb:34:in block in app_call'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in block in resolve'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in each'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in inject'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:118:in resolve'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:109:in fulfilling'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:84:in block in fulfill'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:84:in synchronize'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:84:in fulfill'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:136:in protected_yield'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/promise_pool-0.9.0/lib/promise_pool/promise.rb:49:in block in defer'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-builder-0.9.1/lib/rest-builder/engine.rb:28:in call'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/auth_basic.rb:10:in call'", "/Users/ashwini/no-rocket-science/sw-web/lib/fluke/token.rb:24:in call'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/cache.rb:29:in app_call'", "/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/cache.rb:25:in call'",
"/Users/ashwini/.rvm/gems/ruby-2.3.3/gems/rest-core-4.0.1/lib/rest-core/middleware/common_logger.rb:12:in call'",

from rest-core.

godfat avatar godfat commented on August 12, 2024

This means that the response was claiming to be UTF-8 encoded however it's not. Do you have the original response available?

Suppose this is really the case, what could we do here? We can't reliably parse the JSON without knowing the correct encoding. We could somehow try to fix the response, but that would cause data loss and might not give desired result.

from rest-core.

SunnyKukkarFluke avatar SunnyKukkarFluke commented on August 12, 2024

Hi @godfat,

We are getting an xlsx file as response of this API. Here are the response headers which we are getting in postman:

connection →keep-alive
content-disposition →attachment; filename=FC3540Report1503054716877.xlsx
content-length →189062
content-type →application/xlsx
date →Fri, 18 Aug 2017 11:11:57 GMT
expires →: 0
x-application-context →application:7300

from rest-core.

godfat avatar godfat commented on August 12, 2024

We need the response body to figure out the encoding issue. However on the other hand, it seems like the response was actually an XLSX file, which is not JSON, therefore you shouldn't use JsonResponse middleware.

What's the actually code you're using? If you're using Universal, you should disable :json_response.

from rest-core.

SunnyKukkarFluke avatar SunnyKukkarFluke commented on August 12, 2024

godfat,

Once we are calling get api of rest core using "rest_core_obj.request_full(data)" to download XLSX.
I am also surprised even if in response header the content-type is mentioned as XLSX, why its encoding as json.

from rest-core.

godfat avatar godfat commented on August 12, 2024

@SunnyKukkarFluke You could try:

rest_core_obj.request_full(data.merge(:json_response => false))

The built-in middleware was not designed to download anything, so if you want to do different stuffs with the same client object, then you should write your own middleware.

from rest-core.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.