From d478bc8ef2b1bc49188a876b474e195969ee14aa Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 19 Oct 2020 16:45:10 +0200 Subject: [PATCH] Fixes issue #3250 - Migration from OTRS error - could not find a valid input encoding (EncodingError) --- lib/import/otrs/requester.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/import/otrs/requester.rb b/lib/import/otrs/requester.rb index f96f0872a..243c9a67b 100644 --- a/lib/import/otrs/requester.rb +++ b/lib/import/otrs/requester.rb @@ -18,6 +18,9 @@ module Import # @option opts [Boolean] :diff request only changed/added entries since the last import # # @example + # Import::OTRS::Requester.load('Ticket', offset: '208', limit: '1') + # #=> [{'TicketNumber':'1234', ...}, ...] + # # Import::OTRS::Requester.load('State', offset: '0', limit: '50') # #=> [{'Name':'pending reminder', ...}, ...] # @@ -95,7 +98,7 @@ module Import end def handle_response(response) - encoded_body = response.body.to_utf8 + encoded_body = response.body.to_utf8(fallback: :read_as_sanitized_binary) # remove null bytes otherwise PostgreSQL will fail encoded_body.delete('\u0000') JSON.parse(encoded_body)