Publish API

API for trigger publish from a specific scenario

Examples in this guide reference code from the APS Web Service Client Sample project with a web service proxy configured. If you are just getting started with the APS Web Services APIs, please see our client sample.

API Function

The Publish API is used to automatically export data from PlanetTogether using the scenario publish settings.

API Parameters

  • Username (string) - the user's username performing the call
  • Password (string) - the user's related password
  • TimeoutDuration (TimeSpan) - the time to wait when trying to connect to Extra Services or getting a data lock. If this parameter is not included in the request, a default value of 30 seconds will be used.
  • ScenarioId (long) - Id of the scenario.
  • PublishType (int) - the type of export to perform. Corresponds to the publish destination. Zero is the default.

    0 ToDatabase
    1 ToXML
    2 Custom publish routine
    3 Publish to all configured data sources
    4

    Analytics

API Call

Once the typed Request is created, the API call can be made using the following format:

//Sending a request
ApsWebServiceResponseBase resp = client.Publish(publishRequest);

API Request

This API request inherits from ApsWebServiceRequestBase. Check out our KB article on the API Request Base classes to learn more: Basic API Structure

To use the API, you must create a typed Request using the Request Data Contract. The related web client will use this Request to trigger the process.

  • Data Contract
[DataContract]
public class PublishRequest : ApsWebServiceScenarioRequest
{
[DataMember(IsRequired = false)]
public int PublishType { get; set; } = 0;
}
  • Request Example
//Create a Publish request
client.Publish(new PublishRequest() {
PublishType = 0
});

    API Request

    This API request inherits from ApsWebScenarioRequest. Check out our KB article on the API Request Base classes to learn more: Basic API Structure

    To use the API, you must create a typed Request using the Request Data Contract. The related web client will use this Request to trigger the process.

      Request Example

      //Create a Publish request
      client.Publish(new PublishRequest() {
      PublishType = 0
      });

      //Request Base
      importRequest.UserName = username;
      importRequest.Password = pwd;
      importRequest.TimeoutDuration = TimeSpan.FromMinutes(1);
      //Scenario Request
      importRequest.ScenarioId = long.MinValue; //long.MinValue will publish the Live scenario.

      API Response

      All API calls return a Response object to help determine the result of the call. Check out our Basic API Structure KB article for more information.

      Response Example

      //Sending a request
      start = DateTime.Now;
      ApsWebServiceResponseBase resp = client.Publish(publishRequest);
      Console.WriteLine($"Response received after '{DateTime.Now.Subtract(start)}'");

      //Display results
      if (!a_response.Exception)
      {
      Trace($"Completed with Zero Errors");
      }
      else
      {
      Trace($"Completed with Errors");
      Trace(a_response.FullExceptionText);
      }