# ServiceHasValidLicense Method

## Overloads

| [ServiceHasValidLicense(LicenseType, Guid)](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api7.IQMS7.ServiceHasValidLicense.htm#PIX_Services_V12_Api7_IQMS7_ServiceHasValidLicense_PIX_QMSAPI_DataObjects_Enums_LicenseType_System_Guid_) |  | Checks a service to see whether it has a valid license or not. |
| --- | --- | --- |

[](https://help.qlik.com/en-US/qlikview-developer/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api7.IQMS7.ServiceHasValidLicense.htm) [](https://help.qlik.com/en-US/qlikview-developer/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api7.IQMS7.ServiceHasValidLicense.htm)

## ServiceHasValidLicense(LicenseType, Guid)

Checks a service to see whether it has a valid license or not.

### Declaration

```

          bool ServiceHasValidLicense(LicenseType licenseType, Guid serviceID)
    
  
```

### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [LicenseType](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.Enums.LicenseType.htm) | licenseType | The type of license to check. |
| System.Guid | serviceID | The ID of the service to check. |

### Returns

| Type | Description |
| --- | --- |
| System.Boolean | True if the service has a valid license, otherwise false. |

### Remarks

##### security

Requires membership of local group *QlikView Management API*.

### Examples

This example checks whether the publisher license is valid or not and prints the result.

The service key injection is assumed to be handled behind the scenes. For an example of how to inject the service key, see Samples.

```
using System;
using System.Collections.Generic;
using System.Linq;
using QMSAPI;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // create a QMS API client
            IQMS apiClient = new QMSClient();

            //retrieve a time limited service key
            ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();

           bool hasPublisherLicense = apiClient.ServiceHasValidLicense(LicenseType.Publisher, Guid.Empty);

           if(hasPublisherLicense)
               Console.WriteLine("The publisher license is valid.");
           else
               Console.WriteLine("The publisher license is not valid.");
        }
        catch(Exception e)
        {
            Console.WriteLine("An error occured when validating the license: " + e.Message);
        }
        // wait for user to press any key
        Console.ReadLine();
    }
}
```

### See Also

[LicenseType](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.Enums.LicenseType.htm)