view raw
Craig D Craig D - 6 months ago 46
C# Question

Problems calling "Get Updated" records from using REST API

The following page describes the process for getting a list of updated items from SFDC via the RESTful API.

I know my logic works completely fine for accessing objects etc, so it doesn't appear to the be the way I'm authenticating, or managing the response, but I get "404-Not Found" when accessing the URL as per the code below (simplified for the purposes of this example).

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("​​​?start=2013-11-20T00:00:00+00:00&end=2013-11-24T00:00:00+00:00");
request.Headers.Add("Authorization", "Bearer " + sessionId);
var response = request.GetResponse();
var datastream = response.GetResponseStream();
var reader = new StreamReader(datastream);
var content = reader.ReadToEnd();

I've been able to get the Bulk API going to do this in the past, but I'd prefer the more direct REST API (rather than polling to wait for jobs and batch to complete).

Anyone got this going?


This doesn't make a lot of sense, but I have resolved the issue.

Firstly, there was an error in the documentation, as the time formats in the examples didn't actually work, but using 2013-11-20T00:00:00Z as the time format did work....but that wasn't the major hitch.

It turns out that (using Fiddler at - thanks guys!!) I noticed that there were extraneous characters being inserted into the actual string being sent to the web service.

I started by creating a Uri by calling the Uri(String, Boolean) constructor with "true" as the second parameter, and then removing the fwd slash between the "updated" segment and the ?

If anyone can explain the escaping of ? characters in the string parameter to create a Uri, that would be really helpful, because the documentation seems to suggest that this should be obsolete for .Net Framework 4.0, but this seems to be clearly not the case.