2

Problem:

I'm looking for the REST API that would retrieve on-demand a large number of records in bulk from the Salesforce accounts and other tables. This is to faciliate integration of Salesforce data with a 3rd party system that requires customer information.

I'd like to use use Bulk API via REST to provide access to data. Choice of development language is C#/.NET and need to build a scheduled process on my end to basically move the data out of Salesforce, massage it, integrate it with other on-premise data, and then into the third-party app.

I've been reading this guide: http://www.salesforce.com/us/developer/docs/api_asynch/api_bulk.pdf but need guidance on how to best access REST BulkAPI (and if there even is a REST version of the Bulk API)

All of the examples in .NET so far use SOAP. All of my REST queries against the endpoints specified in the PDF document have resulted in 400 Bad Request

Appreciate any advice!

EDIT: Here's an example of the code I'm trying to run. I've gotten the session ID from using SOAP api's login method. I've tried different variations of the Authorization and Session headers (with and without username) and I've tried different endpoints and different versions. I don't have a job 123 or a batch 123 defined, but I'd be looking for a 404 and not Bad Request which to me says that I'm doing something COMPLETELY wrong.

    var request = WebRequest.Create("https://cs15.salesforce.com/services/async/u/10.0/job/123/batch/123");
    request.Method = "GET";
    request.ContentType = "application/xml";
    //request.Headers.Add("X-SFDC-Session", result.sessionId);
    request.Headers.Add("Authorization", result.userId + " " + result.sessionId);

    var response = request.GetResponse();
3
  • Can you post some of the REST queries you're executing? – Mike Chale Aug 21 '13 at 16:17
  • I've posted the test c# code – Igorek Aug 21 '13 at 16:28
  • Not a solution, but a tool: blog.deadlypenguin.com/blog/2017/08/08/… Using postman you can play with the api a lot easier and perhaps understand the authentication better. Hope this helps a bit – Marco Pietersen Mar 6 '18 at 12:01
3

to set the sessionId header you want

req.setHeader("X-SFDC-Session", result.sessionId);

see the docs for an example request. (the Bulk API uses something different than the regular REST API).

Also, look a the response body you get from your request, it'll have more info on why its wrong, e.g. when i make a request with the same path you have, i get

> GET /services/async/u/10.0/job/123/batch/123 HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8x zlib/1.2.5
> Host: na1.salesforce.com
> Accept: */*
> X-SFDC-Session: [SomeSessionId]
>
< HTTP/1.1 400 Bad Request
< Date: Wed, 21 Aug 2013 17:16:07 GMT
< Content-Type: application/xml
< Transfer-Encoding: chunked
<
<?xml version="1.0" encoding="UTF-8"?><error
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
 <exceptionCode>InvalidUrl</exceptionCode>
 <exceptionMessage>unknown version: u</exceptionMessage>

The docs also have details on the correct URI patterns to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.