dtmtec / restforce-bulk

Client for Salesforce Bulk API
MIT License
7 stars 45 forks source link

Setting compress = true is throwing parse errors #8

Open erlandsona opened 7 years ago

erlandsona commented 7 years ago

config/initializers/restforce.rb

Restforce.configure do |config|
  config.api_version = '40'
  config.compress = true
end

Then when I do the following like in the examples...

client = Restforce.new
job = Restforce::Bulk::Job.create(:insert, 'Contact', :csv)

I get the following error

Faraday::ParsingError: 1:1: FATAL: Start tag expected, '<' not found
        from (irb):13

Which I tried debugging

#<Faraday::ParsingError wrapped=#<Faraday::ParsingError wrapped=#<MultiXml::ParseError: 1:1: FATAL: Start tag expected, '<' not found>> response=#<Faraday::Response:0x007fdcfe39b010 @on_complete_callbacks=[], @env=#<Faraday::Env @method=:post @body="\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x00}\x93As\x9B0\x10\x85\xEF\xFE\x15\fw#\xD9q\xEA\xC6\x83\x95!\xEE\xA4\xF1\xA4\x99$-\xCD!7Y,\t\x19\x90\x18i\x1D\x87\x7F\x9F\xC5\xB86\x05Z\x0E\xCC\xF0\xDE\xF7v\x17\x8D6\xBC\xFC(r\xEF\x1D\xAC\xCB\x8C^\xFA\x93\x80\xFB\x1Ehe\x92L\xBF,\xFD\xDF\xF1\xF5\xF8\xAB\x7F)\xC27\xB3Y\xEB\xD4\x8C<\xCF#^\xBB\xA5\xFF\x8AX.\x18\xDB\xEDvAj\xAC\x82@\x99\x82M9\xBF`\xFC\v\x93\xAE\xD2J\x96\x19K$\xCA\xDC\xC8\xC4\x17#/\xCC\x121?\xE7\xE9\x8C\xEF\x9F\x9B\x1F\xCFi\x14\xDD\x87\x8Cd2M\tV\"\r!2\xED\xC0b\xC8NJmo\xDE@\xA1X\x19\x8DR\xD5f\xF3M\x8E\xB2 \x11\x92\xABj\x9D\b\xCE\xCF\xFF\x94\x7FL\xBF\xE7Qt\e\xB2\xB6\x7F\xC2\xBF\xD1KL\xF9d>\xE6\xF3\xF1d\x1EO\xF9\x82\x9F-fg\x01E\x9F\x8F\xA1=E!W9\x84\xE2\xCE$\x0EeQ\xFE'\xD7\x01\xEB(\xD65\xEEK\xD0\xE4\xE2\xA1\x9E2Zm\xAD\xA5\x83\xAE\x88\x05\xF1 \xAD\xCCs\xC8\xA9q\xC7i`\x04\x8DqU\x82X\xFDz\xDA3G\x81|\xBD-6`\xAF$\xAAWp\x8F[\xD8\x02\x1DD\xC8\x86\xE4.\xBD\xD6\x0F\xD6\xBCXp\xAE\x97hY\xDD\xD4\xCA\x14e\x0E8\xD0\xE6\xE4t3\xD72\xCB\a\x02\a\xB9K\xC7\x86\xAEM\x0Fn\xD4#\xFB\x13\x94\xB1\x89\xA31\x15M\xD9.\xDEsZ\x19\xB4\x19\xB86\xDA\bD\xD0}}j\xF6@\xCCx@DK\xE86\xED\xFE\xCE\xDF2\xD1X\xCFz\x18\x80V)\xCE\n\xA8\xE9!\xB9i\x1D)\xCC\xDE\xA1\x9F\xF8\x97\xB5O\xC1\xC7P\xA0\xA7\x8EBvX`\xF1\tb\x9B:\x80\xF0\x03\x00\x00" @url=#<URI::HTTPS https://na59.salesforce.com/services/async/40/job> @request=#<Faraday::RequestOptions (empty)> @request_headers={"User-Agent"=>"Faraday v0.12.1", "Content-Type"=>"application/xml ;charset=UTF-8", "Authorization"=>"OAuth 00Df4000000lO3n!AQ8AQPHmmIvN0.7Xljfk31Owu5KOpB3VKVAq8fPUa9Sydhz3GBRpBosuiQIxaB0ufp.av0Mp6AHZEwUBtfxNlJK8I3KIDql9", "X-SFDC-Session"=>"00Df4000000lO3n!AQ8AQPHmmIvN0.7Xljfk31Owu5KOpB3VKVAq8fPUa9Sydhz3GBRpBosuiQIxaB0ufp.av0Mp6AHZEwUBtfxNlJK8I3KIDql9", "Accept-Encoding"=>"gzip"} @ssl=#<Faraday::SSLOptions verify=true> @response=#<Faraday::Response:0x007fdcfe39b010 ...> @response_headers={"date"=>"Mon, 17 Jul 2017 20:03:43 GMT", "strict-transport-security"=>"max-age=31536000; includeSubDomains", "x-content-type-options"=>"nosniff", "x-xss-protection"=>"1; mode=block", "content-security-policy"=>"referrer origin-when-cross-origin; upgrade-insecure-requests", "set-cookie"=>"BrowserId=Vzse3nw3Tze7JoblQVWRCA;Path=/;Domain=.salesforce.com;Expires=Fri, 15-Sep-2017 20:03:43 GMT", "expires"=>"Thu, 01 Jan 1970 00:00:00 GMT", "location"=>"/services/async/40.0/job/750f4000000HLZfAAO", "content-type"=>"application/xml", "content-encoding"=>"gzip", "transfer-encoding"=>"chunked", "connection"=>"close"} @status=201 @reason_phrase="Created">>>

From that it looks like Faraday is trying to parse the gzipped response as plain text xml.

erlandsona commented 7 years ago

Any help figuring out why this is happening would be greatly appreciated.