Forum Discussion

donfouts_363600's avatar
donfouts_363600
Icon for Nimbostratus rankNimbostratus
Apr 24, 2019

is there a place to find a resource's required configuration identifies?

I am getting the following error: one or more configuration identifiers must be provided

I am POST to https://$f5ip/mgmt/tm/ltm/virtual/~Common/

below is the payload i am passing as the body json

{
    "source":  "0.0.0.0/0",
    "ipProtocol":  "tcp",
    "description":  "autocreated sitename_vs",
    "rateLimit":  "disabled",
    "destination":  "VIP:443",
    "mask":  "255.255.255.0",
    "rules":  [
                  "_sys_https_redirect"
              ],
    "Name":  "sitename_vs",
    "sourceAddressTranslation":  {
                                     "type":  "automap"
                                 },
    "pool":  "poolname_pool",
    "partition":  "Common"
}

I have read through the icontrol rest api user guide, but found little help.

thanks,

3 Replies

  • This one works for me:

    POST https://{{bigip_a_mgmt}}/mgmt/tm/ltm/virtual
    

    And the body:

    {
        "source":  "0.0.0.0/0",
        "ipProtocol":  "tcp",
        "description":  "autocreated sitename_vs",
        "rateLimit":  "disabled",
        "destination":  "10.23.98.222:443",
        "mask":  "255.255.255.255",
        "rules":  [
                  "_sys_https_redirect"
              ],
        "name":  "sitename_vs",
        "sourceAddressTranslation":  {
                                     "type":  "automap"
                                 },
        "profiles" : [ {
            "kind" : "ltm:virtual:profile",
            "name" : "http"
        }],
        "pool":  "pool_test",
        "partition":  "Common"
    }
    

    I had to correct "Name" to "name", the mask from "255.255.255.0" to "255.255.255.255" and add the http profile. This is needed when using the _sys_https_redirect iRule.

  • this is the corrected code = after following the answer below,

     

    but i wanted to post this for any other Powershell users out there...

     

                                     
        virtual server creation      
                                     
    
    
    $snap = @{}
    $snap.Add('type','automap')
    $snapp = $snap | convertto-json
    
    $profile = @{}
    $profile.add('kind','ltm:virtual:profile')
    $profile.add('name','http')
    $profile.add('partition','Common')
    
    
     check to see if vs is already created
    $uri = "https://$f5ip/mgmt/tm/ltm/virtual/$vs"
    reset err value
    $err = $false
    try{$resp=Invoke-WebRequest -Method Get -Uri $uri -insecure -Headers $headers -Credential $credentials}catch{$err = $_.Exception}
    
    if($err.Response.statuscode -match 'NotFound')
    {
        write-error 'returned a 4xx, virtual server must not exist'
         create https vs
        $URI = "https://$f5ip/mgmt/tm/ltm/virtual"
        $rules = @("_sys_https_redirect")
    
        $body = @{"name"="$vs";
            "partition"="Common";
            "rateLimit"="disabled";
            "ipProtocol"="tcp";
            "source"="0.0.0.0/0";
            "destination"="${stgvip}:443";
            "mask"="255.255.255.255";
            "description"="autocreated $vs";
            "pool"=$PoolName;
            "profiles"= @($profile);
            "sourceAddressTranslation"=$snap}
    
        $JSONBody = $body | ConvertTo-Json 
        $newvirtualserver = invoke-webrequest -Method POST -URI "$URI" -Insecure -Body $JSONBody -Headers $headers -Credential $credentials
    }else{
        write-error 'server already exists'
    }