Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

ModuleCustomCommand()

hitmanpt edited this page Feb 17, 2017 · 1 revision

Through this explanation we assume that you have using WHMCS_API; on the begining of the file
And the API() class initialized as _api
If needed check the Getting Started page

Contents


Function Overview

Prototype: public bool ModuleCustomCommand(int ServiceID, string Command, bool getException = true)

Input:

  • ServiceID: The service ID to run the action for (required)
  • Command: The name of the custom function to run (required)
  • getException: When this command results an error throws an Exception with the error message otherwise only returns false (optional [default: true])

Output: Boolean value whether the command ran successfully or not

Exception: "An API Error has Ocurred" witch contains an inner exception with further explanation of the error (enabled if getException is set to true)


Function Details

To call it just use bool mcc = _api.ModuleCustomCommand(1, "someCommand", false);

The result will be true if the command ran successfully and in this case if there is an error it will be false. To get the error you need to change de last parameter (getException) to true (default value) if the getException is set to true and there was an error on the command an exception will be thrown, "An API Error has Ocurred", witch contains an inner exception with further explanation of the error

WHMCS API Reference: https://developers.whmcs.com/api-reference/modulecustom/

Donate


Full example

using WHMCS_API;

namespace YourApp
{
  class YourClass
  {
    public void YourFunction()
    {
       API _api = new API("username", "password", "accesskey", "url");    
       bool mcc = _api.ModuleCustomCommand(1, "SomeCommand", false);
       Console.WriteLine("Did the command ran without errors? {0}", mcc.ToString());
    }
  }
}