Technical Forum
Ask questions. Discover Answers.
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

Error code 400 while downloading a file via REST API


Hello Everyone,


My GET request to the device is


And the error I receive is,


{ "code": 400, "message": "Requested file size 3165860 greater than maximum chunk size 1048576 allowed", "referer": "", "restOperationId": 14388536, "kind": ":resterrorresponse" }


I am able to transfer the file via SCP. Is there any workaround to download the same via API? Please confirm.



F5 Employee
F5 Employee

I can think of one workaround.

allows you to download a file under the
directory, however, the feature (API) is only available on 13.1.0 or later. For example, to download

curl https:///mgmt/shared/iapp/file-management/sat/sat.txt

You can use the

endpoint and execute
command, however, you need to cleanse the response as the file content is JSON formatted: e.g.,

curl https:///mgmt/tm/util/bash \
  -X POST -H "Content-Type: application/json" \
  -d "{\"command\":\"run\", \"utilCmdArgs\": \"-c 'cat /tmp/sat.txt'\"}"

The response looks like this (The bold part is the file content: 5 lines of text. Note that LF is represented as the literal \n (0x5c 0x6e)):

{"kind":"tm:util:bash:runstate","command":"run","utilCmdArgs":"-c 'cat /tmp/sat.txt'","commandResult":"Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n"}

F5 Employee
F5 Employee

The maximum octets you can download using the

endpoint is 1,048,576 bytes (1 MiB = 1,0242). Any remaining data is silently truncated (I did not get the 400 error you got. Possibly version dependent. Mine was 13.0.0).

When you need to download a file larger than this limit, download chunk by chunk by using the

header. For example, to download a 3,165,860 bytes file, use the REST call three times.

GET /mgmt/tm/asm/file-transfer/downloads/file > file     ... first 1 MiB
GET /mgmt/tm/asm/file-transfer/downloads/file -H "Content-Range: 1048576-2097151/3165860"
>> file     ... next 1 MiB
GET /mgmt/tm/asm/file-transfer/downloads/file -H "Content-Range: 2097152-3165860/3165860" >> file    ... the remaining octets

See also Demystifying iControl REST Part 5: Transferring Files for the Content-Range header format.

Isn't "Content-Range" issued by the server? The client side should use "Range:" instead in its request.

It is implemented that way presently. F5 is aware of the discrepancy with RFC 7233 and has a bug ID assigned to the issue: ID701702.


after receiving this file how can be store it to read it? does storing in *.txt format work ?


That clears it up. Thanks!

F5 Employee
F5 Employee

As shown above, >> (double redirect) should append the data (HTTP response) to the file. If you are using curl, -o (hyphen o) option is also handy.

Regarding the file extension, it depends on the type of file (data) you download. If you are downloading an jpeg image, then its' natural to add the .jpg extension to the filename and open with an image viewer (although Unix does not rely upon file extensions, I personally prefer to add appropriate one). If the data is text, yes, use .txt and open with an text editor of your choice.

F5 Employee
F5 Employee