Forum Discussion
Randy_Toombs_35
Nimbostratus
Sep 24, 2018Uploading ASM policy files?
I am trying to use the REST API to upload multiple ASM policies to a new install. I have followed the instructions found in the REST API guide (https://devcentral.f5.com/wiki/icontrolrest.icontrolre...
suttonsc
Employee
Nov 28, 2018When uploading you need to add the file itself and the headers:
>>> response = requests.post(url=uploadPolicy+fileName,verify=False,auth=("admin","admin"),data=open('test.xml', 'rb'),headers={'Content-Type': 'application/octet-stream', 'Content-Range': '0-402287/402288'})
>>>
>>> response.status_code
200
>>>
>>> print(response)
>>>
>>> response.content
b'{"remainingByteCount":0,"usedChunks":{"0":402288},"totalByteCount":402288,"localFilePath":"/ts/var/rest/admin~test.xml","temporaryFilePath":"/ts/var/rest/tmp/admin~test.xml","generation":0,"lastUpdateMicros":1543445350182166}'
Or using curl:
curl -sku admin:admin -X POST https://155.140.lab.es.f5net.com/mgmt/tm/asm/file-transfer/uploads/test.xml -H "Content-Type: application/octet-stream" -H "Content-Range: 0-402287/402288" --data-binary "@test.xml" | jq .
{
"remainingByteCount": 0,
"usedChunks": {
"0": 402288
},
"totalByteCount": 402288,
"localFilePath": "/ts/var/rest/admin~test.xml",
"temporaryFilePath": "/ts/var/rest/tmp/admin~test.xml",
"generation": 0,
"lastUpdateMicros": 1543445684953045
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects