title: How do you create a page using the API for sharepoint 2010?
body: <p>I have just started using Sharepoint Foundation 2010 and I'm trying to write a function from c# to add pages to a site.</p>
  
  <p>I got some code working to create a new site, but I can't seem to find any documentation about adding a page to an existing site using the client object model.</p>
  
  <p>This is probably a simple question but if anyone can help me out I would appreciated it.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Update</strong></p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>private void createPage()
      {
          ClientContext context = new ClientContext(url);
          Site siteCollection = context.Site;
          Web site = context.Web;
  
          List pages = site.Lists.GetByTitle("Pages");
          FileCreationInformation fileCreateInfo = new FileCreationInformation();
          fileCreateInfo.Url = "NewPage";
          fileCreateInfo.Content = System.Text.Encoding.ASCII.GetBytes("Test");
          context.Load(pages.RootFolder.Files.Add(fileCreateInfo));
  
          context.ExecuteQuery();
          context.Dispose();
      }
  </code></pre>
  
  <p>But I get a server exception "List 'Pages' does not exist at site with URL"</p>