Projects: Add Projects

Collapse All

URL

http://api.fonts.com/rest/{format}/Projects/

{format}

xml or json

Method

POST

Required Header Parameters:

  • authorizationHashed authorization key
  • appkeyYour application’s key

Required Query String Parameters:

  • None

Optional Query String Parameters:

  • wfspstartstarting record requested (zero-based)
  • wfsplimit# of records requested

Required Data Parameters

  • wfsproject_nameName of new project

Response variables:

  • MessageIf the response is successful then the “message” parameter of the response will be “Success” and if there is some error or failure then the “message” parameter will be the error message.
  • UserIdUser Id number
  • UserRoletype of account
    • Free: resembles the free user
    • Standard: resembles the premium users with limited features
    • Pro: resembles the premium users with full features
    • Custom: resembles a custom users
  • Project: ProjectNameName of the Project
  • Project: ProjectKeyToken used to list the Project’s domains,fonts and selectors
  • TotalRecordsTotal number of records
  • PageStartstarting record requested (zero-based)
  • PageLimit# of records requested

Sample Code

PHP

<?php

require_once('Services_WFS.php');

$services = new Services_WFS;

$apiKey = '[Your API Key]';
$publicKey = '[Your Public Key]';
$privateKey = '[Your Private Key]';
$services->setCredentials($publicKey, $privateKey, $apiKey);

$services->setAutoPublish(1); // do not auto publish

$result = $services->addProject('Project Blue');

var_dump($result);

$newProject = $result['Project Blue'];


?>        

C#

  private string AddProject(string projectName, int pageStart, int pageLimit)
  {

    const string method = "POST";
    string requestUri = "/rest/" + Format + "/projects/" + 
                                            "?wfspstart=" + pageStart + 
                                            "&wfsplimit=" + pageLimit;

    string data = "wfsproject_name=" + projectName;

    //See common functions for GetResponse
    return GetResponse(method, requestUri, data);

  }
        

VB.NET

  Private Function AddProject(ByVal projectName As String, ByVal pageStart As Integer, ByVal pageLimit As Integer) As String

    Const method As String = "POST"
    Dim requestUri As String = "/rest/" & Format & "/projects/" & _
                               "?wfspstart=" & pageStart & _
                               "&wfsplimit=" & pageLimit

    Dim data As String = "wfsproject_name=" & projectName

    'See common functions for GetResponse
    Return GetResponse(method, requestUri, Data)

  End Function

XML Response

<Projects>
  <Message>Success</Message>
  <UserId>1025405</UserId>
  <UserRole>Free</UserRole>
  <Project>
    <ProjectName>test5</ProjectName>
    <ProjectKey>eaa004dc-2872-4bd7-bd15-a59d1ea575c3</ProjectKey>
  </Project>
  <Project>
    <ProjectName>test1</ProjectName>
    <ProjectKey>9bfa8382-020d-4814-83ae-7b6da1c47202</ProjectKey>
  </Project>
  <Project>
    <ProjectName>test2</ProjectName>
    <ProjectKey>e04da95f-fe70-4f73-b3d9-d2d621472280</ProjectKey>
  </Project>
  <Project>
    <ProjectName>test3</ProjectName>
    <ProjectKey>3c86c27b-ec59-4e8e-acdd-9b89c9f13c8b</ProjectKey>
  </Project>
  <Project>
    <ProjectName>test4</ProjectName>
    <ProjectKey>81151825-c20b-44c1-8f1e-67473b8b9a37</ProjectKey>
  </Project>
  <TotalRecords>5</TotalRecords>
  <PageStart>0</PageStart>
  <PageLimit>10</PageLimit>
</Projects>

Json Response

{
   "Projects":{
      "Message":"Success",
      "PageLimit":"10",
      "PageStart":"0",
      "Project":[
         {
            "ProjectKey":"eaa004dc-2872-4bd7-bd15-a59d1ea575c3",
            "ProjectName":"test5"
         },
         {
            "ProjectKey":"9bfa8382-020d-4814-83ae-7b6da1c47202",
            "ProjectName":"test1"
         },
         {
            "ProjectKey":"e04da95f-fe70-4f73-b3d9-d2d621472280",
            "ProjectName":"test2"
         },
         {
            "ProjectKey":"3c86c27b-ec59-4e8e-acdd-9b89c9f13c8b",
            "ProjectName":"test3"
         },
         {
            "ProjectKey":"81151825-c20b-44c1-8f1e-67473b8b9a37",
            "ProjectName":"test4"
         }
      ],
      "TotalRecords":"5",
      "UserId":"1025405",
      "UserRole":"Free"
   }
}