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'm trying to check out a file using the Lists web service. Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Soap = System.Web.Services.Protocols;

namespace SharepointTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                WebService.Lists listsService = new WebService.Lists();
                listsService.Url = "http://wss/sites/WebService/_vti_bin/lists.asmx";
                listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                console.WriteLine(listsService.CheckOutFile("http://wss.test.com/sites/WebService/Test File.xlsm", "false", "Wed, 28 Nov 2012 14:17:50 GMT"));

            }
            catch(Soap.SoapException ex)
            {
                Console.WriteLine("<br>File Check Out Exception: " + ex.Detail.InnerText);
                Console.ReadLine();
            }
        }
    }
}

I obtained the date parameter for CheckOutFile() by using GetListItems() to get the Last Modified field contents. The call to CheckOutFile() raises the following SoapException:

"Save Conflict"

"Your changes conflict with those made concurrently by another user. 
If you want your changes to be applied, click Back in your Web browser,
refresh the page, and resubmit your changes.0x8107054a"

I can see in my web browser that the file is not currently checked out to anyone, and I can check it out and in through the browser. Any idea why I can't use CheckOutFile()?

share|improve this question
add comment

1 Answer

I figured out what was wrong. The date string was actually in PST, not GMT; I needed to convert it to the correct GMT using the following code:

public static string convertToGMT(DateTime dt)
        {
            TimeZoneInfo pst = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
            DateTime utc_dt=TimeZoneInfo.ConvertTimeToUtc(dt, pst);
            string output = utc_dt.ToString("r");
            return output;
        }
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.