Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Create a nightly batch export from a sharepoint list

  Asked By: Janak    Date: Nov 10    Category: Sharepoint    Views: 7338

I'm new to coding against
the sharepoint object model, being a SQL DBA and business analyst who in
the last year has taken over administering my company's SharePoint
intranet. But enough of my background. [:)]

I am currently trying to pull data from a purchasing requisition system
that was written using InfoPath forms to promote fields to a SharePoint
list ("Purchasing Requisitions"). The InfoPath form has header
information and a variable number of detail rows, so the rows of the
purchasing requisition are not promotable to the list metadata.
Therefore, I am trying to use the SharePoint object model to read the
rows, which store all the financial data. Once I can read the rows, I
know how to store them in SQL and use them in our accounting system. My
trouble is finding the row detail data using the SharePoint object
model! I have tried SPListItemCollection and SPFileCollection, and I
can only get so far.

The code I am running in this example uses the SPListItemCollection

SPSite site2 = new
SPWeb web2 = site2.OpenWeb();

SPListItemCollection Reqs =

string requistionsURL =

int ReqCount = Reqs.Count;

for (int k = 0; k < ReqCount; k++)


SPListItem Req = Reqs[k];

if (Req["Status"].ToString() != null)



//Get the URL:

SPFieldUrlValue linkUrl = new SPFieldUrlValue();

linkUrl.Url = requistionsURL + Req.Title + "?OpenIn=Browser";

// Create a request for the URL.

WebRequest request = WebRequest.Create(linkUrl.Url);

// If required by the server, set the credentials.

request.Credentials = CredentialCache.DefaultCredentials;

// Get the response.

The above code seems to be working.

The next line is where I get an error saying:

"The remote server returned an error: (404) Not Found"

HttpWebResponse response =

// Display the status.


// Get the stream containing content returned by the server.

Stream dataStream = response.GetResponseStream();

// Open the stream using a StreamReader for easy access.

StreamReader reader = new StreamReader(dataStream);

// Read the content.

string responseFromServer = reader.ReadToEnd();

// Display the content.



// Cleanup the streams and the response.





catch (Exception ex)






I do not know what file the httpwebresponse is looking for in the above
code. I must not have set something up properly, but what?

I have also tried coding a different routine using the SPFileCollection
class, but I am finding it difficult to find where the actual data is
located. Using SPFileColleciton, I had trouble getting some methods to
run without an error, such as file.Item .ModerationInformation.Status or
file.Item.ModerationInformation.Comment methods. Using those methods I
get the error: "object does not reference an instance of an object".

If anyone can tell me where the actual data can be found or how to
return a string of the list item XML that I can parse, I would be
greatly appreciate it.



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Create a nightly batch export from a sharepoint list Or get search suggestion and latest updates.