Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am uploading files to SharePoint 2010 following the answer here: Uploading files to Document Libraries using the REST API

The issue is that all of the files are set as checked out due to some required fields in the list. I an using the OData API to update the column values, but I want to automatically check in the files. Is this even possible?

Here's how I'm updating the entities.

    Planning.PlanningDataContext context = new Planning.PlanningDataContext(new System.Uri("http://sharepoint/Service/ds/plan/_vti_bin/ListData.svc"));
    context.Credentials = System.Net.CredentialCache.DefaultCredentials;

    for (int i=0; i < Studies.Count; i++)
    {
        var study = Studies[i];
        PutFileOnSP(study);
        var serverStudy = context.GeotechnicalStudies.Where(s => s.Name == study.Name).FirstOrDefault();
        serverStudy.StudyArea = study.StudyArea;
        serverStudy.StudyPerformedBy = study.StudyPerformedBy;
        serverStudy.StudyNumber = study.StudyNumber;
        context.UpdateObject(serverStudy);
    }
    context.SaveChanges();
share|improve this question
add comment

1 Answer

I don't believe it is possible using the ListData.svc. But you can do it using the Managed Client Side Object Model. I'm not on my dev system right now but I will add a code sample tomorrow.

Edit:

Just to be certain I attempted to check in a document in my dev server's Shared Documents library using ListData.svc. I attempted to do it by sending a DELETE request to

../_vti_bin/ListData.svc/SharedDocuments(1)/$links/CheckedOutTo

I did not receive any error but no modification was made. I also sent a POST request trying to set the CheckedOutToId to null. This didn't work either. So I honestly belive there is no way of doing this via the SP 2010 REST API. Here is example code using the Managed Client Object model. This was tested in a console app on my work laptop to my development server.

        ClientContext clientContext = new ClientContext("http://devserver.domain.com/");
        Web web = clientContext.Web;
        clientContext.Load(web);
        clientContext.ExecuteQuery();
        List sharedDocs = web.Lists.GetByTitle("Shared Documents");
        clientContext.Load(sharedDocs);
        clientContext.ExecuteQuery();
        ListItem item = sharedDocs.GetItemById(1);
        File file = item.File;
        file.CheckIn("Checkin comments.", CheckinType.MajorCheckIn);
        clientContext.Load(file);
        clientContext.ExecuteQuery();
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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