api
72 TopicsRunning BASH commands via REST API
I am trying to run bash commands via the REST API but am getting an error. When trying to use the following syntax I am getting a 403 running with Admin authentication... GET: https://F5LTM/mgmt/tm/util/bash Output: {"code":403,"message":"Operation is not allowed on component /util/bash.","errorStack":[]} Does anyone know if this is possible, or have any syntax examples of how to run bash commands? I assume you need to submit a post request, but I am not sure how to structure the syntax in the body of the request and cannot find any examples.3.8KViews1like3CommentsPowershell: Invoke-RESTmethod on /mgmt/tm/sys/ucs (403) Forbidden error
I'm fairly experienced with Powershell and have used the Invoke-RestMethod cmdlet, and vendor documentation, to automate some things before. I've just inherited management of an HA pair of F5 BIG-IPs. We're not in a position to get BIG-IQ right now, and from looking at notes the previous admin was just logging in and manually creating a UCS archive and downloading it on the weekly. Of course my first thought was that I could automate this. I was able to successfully authenticate against one of the appliances with Invoke-RestMethod and do an HTTP GET to retrieve a list of current UCS files present. However, when I change the method to POST and add in the appropraite Body parameters (in JSON) I get a 403 forbidden error: {"code":403,"message":"Operation is not allowed on component /sys/ucs.","errorStack":[],"apiError":1} the documentation here seems to allude that this should be possible: K13225405 Here's more or less what I'm working with so far: $uri = "/mgmt/tm/sys/ucs" $BigIP = "192.168.1.10" $link = "https://$BigIP$uri" $headers = @{} $headers.Add("ServerHost", $Bigip) $headers.Add("Content-Type", "application/json") $Body = @{ Name = "/var/local/ucs/test_ucs.ucs" Command = "save" } $mycreds = Get-Credential $obj = Invoke-RestMethod -Method POST -Headers $headers -Body ($Body | ConvertTo-Json) -Uri $link -Credential $mycreds3.4KViews0likes19CommentsUsing a swagger file to create an ASM policy for an API in BIG IP Ver-15
Hi, I had heard that in BIG IP Ver15 that you could create an ASM policy for an API using the swagger file for the that API. Can anyone point me in the direction of the documentation on this? We have just upgraded a TEST system to Ver15 and I want to use the swagger file I have to create the policy for the API. Thank you2.9KViews0likes4CommentsCreate a IFile {system level} via API - Powershell
Hi All, Attempting the following: 1: Create iFile system level 2: Update existing iRule-> iFile referance the the file uploaded in step 1. Im getting stuck at step 1, any assistance creatly apprecuated. What I have tried: Get Auth Token: # Get API token $big_ip = 'https://[REDACTED]' $url = "{0}{1}" -f $big_ip, '/mgmt/shared/authn/login' $body = @{ username = "[REDACTED]" password = '[REDACTED]' loginProviderName = "tmos" } | ConvertTo-Json $result = Invoke-RestMethod -Method 'POST' -Uri $url -ContentType 'application/json' -Body $body $token = $($result.token.token) Works. Next, Upload my file: $File_Name = 'MyFile' $File_Upload = 'C:\Temp\MyFile' $url = "{0}{1}{2}" -f $big_ip, "/mgmt/shared/file-transfer/uploads/", $File_Name $filelength = (Get-Item $File_Upload).length $headers = @{ 'Content-Type' = 'application/octet-stream' 'X-F5-Auth-Token' = $token 'Content-Range' = "0-$($filelength-1)/$filelength" } $result = Invoke-RestMethod -Method Post -Uri $url -Headers $headers -InFile $File_Upload Works fine too I am returned with: remainingByteCount : 0 usedChunks : @{0=46321} totalByteCount : 46321 localFilePath : /var/config/rest/downloads/MyFile temporaryFilePath : /var/config/rest/downloads/tmp/MyFile generation : 0 lastUpdateMicros : 1661257236246203 Next is where im stuck, creation of the iFile system level from the uploaded file. Ive re-typed the below from the Curl samples here:Syncing local repositories and ifiles using iContr... - DevCentral (f5.com) ### Create a iFile {system level} - does not yet work $File_Name = 'MyFile' $url = "{0}{1}{2}" -f $big_ip, "/mgmt/tm/sys/file/ifile/", $File_Name $headers = @{ 'Content-Type' = 'application/json' 'X-F5-Auth-Token' = $token } $body = @{ 'name' = $File_Name 'source-path' = "file:///var/config/rest/downloads/$File_Name" } | ConvertTo-Json $result = Invoke-RestMethod -Method put -Uri $url -Headers $headers -Body $body Next I am recieving that the file cannot be found. So this query is incorrectly tructured ? Translated these examples to powershell: Syncing local repositories and ifiles using iContr... - DevCentral (f5.com) Invoke-RestMethod : {"code":404,"message":"01020036:3: The requested iFile (/Common/MyFile) was not found.","errorStack":[],"apiError":3} At line:1 char:11 + $result = Invoke-RestMethod -Method put -Uri $url -Headers $headers - ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand Any assistance appreated with the above & next up updating the iRule file refence.Solved1.9KViews1like10CommentsASM block page for use with API waf policy
Hey all! I´ve setup a asm waf policy for a webservice that handels api calls. But the standard response on a block is a 200 OK with the block webpage, which works great if a person can see it on the screen.. when it´s an api call the service just gets a <!DO (the first characters of the webpage) and a 200 OK. What I want to do I just return a 403 / 503 (or something like that) and just respond with the support ID in a header back to the source. I´ve got most of it figured out, except the header part... So... doesnt anyone know a good way for me to insert a support ID to a header response back to the client?Solved1.7KViews0likes17CommentsAPI Security requirement?
Hi F5 Community, We are new and not familiar to API Security and we would like to ask what information is needed for our client? Is this correct? Swagger File and OAuth Server are the only two items needed? What is an OAuth Server? Apology on this since as said we are really novice on this. Thanks.Solved1.5KViews0likes2CommentsAPI Calls to F5 limited to 1024 KB download
Hi, I am interacting with the F5 API in order to download ASM policies for the purpose of automating the backups. The process works fine however policies larger than 1024 KB are cut off at this size of 1024 KB. Initially I suspected that there was a default limit on the curl request however I have not been able to find information on how to increase this with the curl request. Is this a limitation on the F5 API or the Curl request? wget is not an option as this is not natively supported on the F5 virtual appliance. My script lives on the appliance, downloads the relevant policies and then pushes them to a SMB share. The only issue is that the ASM policies that are larger than 1024 KB are being cut off at 1024 KB. The API calls are as per the documentation here: http://cdn.f5.com/websites/devcentral.f5.com/downloads/icontrol-rest-api-user-guide-13-0-0.pdf specifically: GET https://x.x.x.x/mgmt/tm/asm/policies POST https://x.x.x.x/mgmt/tm/asm/tasks/export-policy GET https://x.x.x.x/mgmt/tm/asm/file-transfer/downloads/$asmPolicy Excluding the processing in my script the API calls I make are shown below: I expect the issue resides in the download api call. Is there a switch I can add to increase this limit? curl -ku 'username:password' -X GET https://x.x.x.x/mgmt/tm/asm/policies | jq '.items[] | "pol_name:" + .name + ";api_id:" + .id' >> $wdir/asmDetails.txt curl -ku 'username:password' -X POST https://x.x.x.x/mgmt/tm/asm/tasks/export-policy -H 'Content-Type: application/json' -d '{"filename":"'$asmPolicy'","policyReference":{"link":"https://localhost/mgmt/tm/asm/policies/'$asmIDs'"}}' curl -ku 'username:password' -X GET https://x.x.x.x/mgmt/tm/asm/file-transfer/downloads/$asmPolicy > $wdir/asmBackup/"$folderName"/$number-$asmPolicy-$hostname-"$dateStamp".xml Thanks1.5KViews0likes16CommentsGetting active pool member connections using Python
If I want to see all of the client connections connecting to a pool member from the CLI I can do something like a "show sys connection ss-server-addr 1.2.3.4". I can also do this using Postman mapping to ";, but I cannot figure out how to do this via Python. Using Python if I try to connect to "bigip.sys.raw" I do not see a module called "connection" or anything similar. Does anyone know how, or have some sample code on how to accomplish this? Thanks!1.2KViews0likes10CommentsModify SSL profiles via REST API
Hi wiz's I have been spending some time on automating certificate maintenance. This has brought my attention to this documentation: https://clouddocs.f5.com/api/icontrol-rest/APIRef_tm_ltm_profile_client-ssl.html In the table descriping "cert", "chain" and "key" it states in the notes that they are depricated and I should use certKeyChain option instead. However no matter what I construct of calls which makes changes to an already existing clientssl profile (PATCH and PUT) I'm told: {"code":403,"message":"Operation is not supported on component /ltm/profile/client-ssl.","errorStack":[],"apiError":1} Example code: curl -sk -H "X-F5-Auth-Token: $TOKEN" -X PATCH https://$f5/mgmt/tm/ltm/profile/client-ssl/ --header 'Content-Type: application/json' --data-raw '{ "name":"sletmig", "certKeyChain":[{"name":"default","cert":"hest.dk_2023","key":"hest.dk_2023","chain":"My_CA"}] }' {"code":403,"message":"Operation is not supported on component /ltm/profile/client-ssl.","errorStack":[],"apiError":1} I can make the change via this syntax: curl -sk -H "X-F5-Auth-Token: $TOKEN" -X PATCH https://$f5/mgmt/tm/ltm/profile/client-ssl/~Common~sletmig -H "Content-Type: application/json" -d '{ "key":"/Common/hest.dk_2023", "cert":"/Common/hest.dk_2023", "chain":"/Common/My_CA" }'|jq Do I read the documentation wrong or am I missing something else? JRahm any hints?Solved899Views1like5Comments