Project File Web Service


Project File Web Service

This web service allows for the uploading of project resource files.

This service is performed through an HTTPS POST to the specified URL.The file to be uploaded will comprise the body of the post.The server will ingest the post, verify authenticity of the parameters, save the file to the appropriate location and return either a success or failure notice.The result is the response code defined by the HTTPS protocol:200 equals OK, 500 equals Internal Server Error.All project restrictions are applied to the file being uploaded.They include, but are not limited to: project size restrictions, file type restrictions and project content restrictions.For example, attempting to upload a JavaScript file (file.js) will result in a response code of 500.

Framework:
All examples are written in C# utilizing the 3.5 .Net Framework.

 
URL:
https://www.four51.com/services/uploadprojectfile.hcf
 
Parameters:
InteropKey (string):Provided by Four51. Email interop@four51.com if you don’t already have an InteropKey.
Path (string): The file name and path information relative to the root of the project directory.For example, Project\Project.pf identifies the projectfile.Project\Images\background.jpg would point to a file in the images directory.You can also update shared files via this method.Shared\users.mdb points to a data file in the shared directory.
ProductInteropID (string):Identifies the product.The value is set via the administrative interface.Navigate to the Product Properties page and find the Interop ID field.


Example:

private void Upload()
{
      string Four51URL = String.Format(
"http://www.four51.com/services/uploadprojectfile.hcf?InteropKey={0}&path={1}&productID={2}",
            "DX6SvMQ36jDNht3uRPXAcHnq1O9xPuXs70SoYpZ53HJmgeXc3 - pxumQ - e - e",
            "Project\Project.pf",
            "BusinessCard001");
 
      HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(Four51URL);
      FileStream fileStream = File.OpenRead(@"C:\Projects\BusinessCard001\Project.pf");
      webRequest.ContentLength = fileStream.Length;
      webRequest.Method = "POST";
      Stream requestStream = webRequest.GetRequestStream();
      byte[] buffer = new byte[32768];
      int bytesRead = fileStream.Read(buffer, 0, buffer.Length);
 
      while (bytesRead > 0)
      {
            requestStream.Write(buffer, 0, bytesRead);
            bytesRead = fileStream.Read(buffer, 0, buffer.Length);
      }
      requestStream.Flush();
      requestStream.Close();
      fileStream.Close();
 
      try
      {
            WebResponse webResponse = webRequest.GetResponse();
            MessageBox.Show("File uploaded successfully!");
      }
      catch (WebException webError)
      {
            string message = "File upload failed:\r\n" + webError.Message + "response: \r\n\r\n";
            MessageBox.Show(message);
      }
}
 

Reference Material:
Four51 Admin Web Service Implementation Guide

Related Articles:
Four51 Admin Web Services

Labels: project file, pageflex, page flex, web service