Coder Social home page Coder Social logo

restforce-bulk's People

Contributors

cwebberops avatar gustavokloh avatar trevorbramble avatar vicentemundim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

restforce-bulk's Issues

Support for multi-tenancy

I have a multi-tenant application, and need to create Batch Jobs for many different Salesforce organizations, which means many different Restforce clients. It would be great if the Job creation API supported that, as it's effectively hard-coded to Restforce::Bulk.client as far as I can tell.

From what I can tell, I can do it by basically re-implementing Restforce::Bulk::Job::create, but that isn't very clean:

# My own application code, used to get Restforce::Data::Client instance for a User.
restforce_client = User.first.get_restforce_client

bulk_client = Restforce::Bulk::Client.new(restforce_client)
job_builder = Restforce::Bulk::Builder::Xml.new(:query)
job_data = job_builder.job('Contact', 'CSV')
job_create_response = bulk_client.perform_request(:post, 'job', job_data)
job = Restforce::Bulk::Job.new(job_create_response.body.jobInfo)

Almost seems like that should be:

bulk_client = Restforce::Bulk::Client.new(restforce_client)
job = bulk_client.create_job(:query, 'Account', :csv)

How do you authenticate?

I'm used to creating Restforce clients with

client = Restforce.new username: USERNAME,
                       password: PASSWORD,
                       security_token: SECURITY_TOKEN,
                       client_id: CONSUMER_KEY,
                       client_secret: CONSUMER_SECRET

and then using client.describe etc. to interact with the API. What do I do differently with Restforce::Bulk?

batch.results doesn't has error

In the README its mentioned to get errors from results of a batch :

batch.results.each do |result|
  puts result.id      # Id of the result
  puts result.success # row successfully processed
  puts result.error   # error for row
end

However, when I implement it, I only get this for result object for a failed record after job is completed(insert):
#<Restforce::Bulk::Result:0x000000000b17fe98 @job_id="7502x0000055VobAAE", @batch_id="7512x000005XpjSAAS", @success="false", @created="false">

Please help me understand how can I get error message.

Setting compress = true is throwing parse errors

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.

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.