UploadPackage() Method

You use the UploadPackage() method to import a customization project from the file system. The method saves the content of an uploaded deployment package to the database of an instance of MYOB Acumatica.

Syntax

public void UploadPackage(string packageName, byte[] packageContents, 
                                    bool replaceIfPackageExists)

Parameters

  • packageName: The name of the customization project to be saved in the database.
  • packageContents: An array of bytes that contains the content of the deployment package .zip file and will be saved in the database.
  • replaceIfPackageExists: An indicator of whether the customization platform must replace an existing customization project with the same name in the database. If the value of this parameter is true and the database contains a customization project with the same name, the platform replaces the project with the specified content. If the value of the parameter is false and the database contains a customization project with the same name, an exception occurs.

Example

The following code logs in to an MYOB Acumatica instance, loads the C:\package1.zip file content, and saves or updates the package1 customization project in the database of the instance.


var webserviceurl = "http://localhost/AcumaticaInstance/api/ServiceGate.asmx";
var username = "admin";
var password = "123";
var packageName = "package1";
var packageContents = File.ReadAllBytes("C:\package1.zip");
var replaceIfPackageExists = true;

var client = new ServiceGate.ServiceGate
{
  Url = webserviceurl,
  CookieContainer = new CookieContainer(),
  Timeout = (int) TimeSpan.FromMinutes(5).TotalMilliseconds
};

var loginResult = client.Login(username, password);

if (loginResult.Code == ErrorCode.OK)
{
  client.UploadPackage(packageName, packageContents, replaceIfPackageExists);
}

Usage Notes

If there are multiple tenants in an instance of MYOB Acumatica, this method affects the tenant to which the service is logged in. To log in to a specific tenant, add the tenant name to the user name using the following format: user@MyTenant.