Showing results for 
Search instead for 
Do you mean 

Using SDataUri and SDataRequest

by on ‎12-05-2011 08:11 AM

Now that I have really been spending some quality time with SData and the SalesLogix .Net client libraries I'm starting to use these to objects more often. Let me show you why.....


The main goal of the SalesLogix client libraries (.Net or Javascript) is to help create well formed REST calls to SalesLogix. They are also amazingly helpful when it comes to manipulating the data returned. Still, all this could be done without the libraries if you really wanted to (an option I have no intent to take).


So, yes, these libraries make things a lot easier but what I'm learning is it's still really convenient to be able to see and form the call in the browser and then pretty much just paste that into my code. This is where the SDataUri and SDataRequest objects come into play.


Below is some code that will execute a group and bring back data.


 var uri = new SDataUri(Properties.Settings.Default.URL + "/sdata/slx/system/-/groups/$queries/execute")
                        Select = "*",
                        QueryArgs = { {"_groupId", dropDownGroup.SelectedItem.Tag.ToString()} },
                        StartIndex = index
                    var request = new SDataRequest(uri.ToString())
                        UserName = Properties.Settings.Default.UserName,
                        Password = Properties.Settings.Default.Password

                    var response = request.GetResponse();
                    var feed = (AtomFeed)response.Content;

 Notice how I used the SDataUri object to create a well formed REST call. The nice (and very important) thing is that I can build calls that might be a little complex or even to other SData systems. The SDataUri object has a number of properties to make your life a lot easier like "Select", "QueryArgs", "StartIndex" to name just a few.


Now all you do is pass this new uri to the SDataRequest object and everything after is pretty much the same as you have done in the past. The request object takes a username and password plus the uri. Based on the query it will return a collection or single result.


I find this a lot easier now because it's the same call for everything and all I have to do is format the uri object to fit my needs. Also, for testing I can just take the results of uri.ToString() and paste that into a browser to see first hand what's going on Smiley Happy


Give this method a try the next time you use SData in your project and let me know what you think!

on ‎03-27-2012 08:49 AM



I am very new to SData. I have successfully used SData to get information from SLX


If this works, this is exactly what I need. 


In your example above you have 'StartIndex =index'. Where did you define and set  'index'?  I assume setting to 0 will get from the begining.


Register Read Guidelines Request Partner or Employee Access

What's New in 8.1