Public/Get-AppEnhancerApplicationFields.ps1

function Get-AppEnhancerApplicationFields {
    <#
    .SYNOPSIS
        This script gets field information for specific application.
 
    .NOTES
        Name: Get-AppEnhancerApplicationFields
        Author: Bruce Stump
 
    .DESCRIPTION
        This script gets field information for specific application in Application
        Enhancer.
 
    .EXAMPLE
        Get-AppEnhancerApplicationFields -AppId $ApplicationId -Cred $credentials -serverUrl $serverUrl
    #>


    param (
        [Parameter(Mandatory=$true)]
        [string]$AppId,
        [Parameter(Mandatory=$true)]
        [pscredential]$Cred,
        [Parameter(Mandatory=$true)]
        [string]$serverUrl
    )

    begin {
        # Define your credentials
        $username = $Cred.UserName
        $password = $Cred.GetNetworkCredential().password
    }

    process {
        # Convert credentials to Base64 for Basic Authentication
        $pair = $username + ':' + $password
        $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
        $base64 = [Convert]::ToBase64String($bytes)
        $authHeader = "Basic $base64"

        # Define headers with Basic Authentication
        $headers = @{
            "Authorization" = $authHeader
            "Content-Type"  = "application/json"
        }

        # Define the URL to get the list of applications
        $applicationsUrl = "$serverUrl/AppEnhancerReST/api/AXDataSources/AEDEV/axappfields/$AppId"

        # Retrieve the list of applications
        Invoke-RestMethod -Uri $applicationsUrl -Method Get -Headers $headers
    }

    end {}
}