Example: Firmware upgrade using REST APIs
Uploading a file as the secondary firmware image
In the following example, a curl command is used to upload the firmware image file from the local workstation to the switch and post that file as the secondary firmware image. The
-F
option specifies that the POST method is used to upload the file.
Method and URI:
POST "https://192.0.2.5/rest/v1/firmware?image=secondary"
Request body:
The request body contains the switch firmware image file in binary format.
Example curl command:
$ curl -k -b /tmp/auth_cookie \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
-F "fileupload=@/myfirmwarefiles/myswitchfirmware_2017020905.swi" \
https://192.0.2.5/rest/v1/firmware?image=secondary
In the curl command, the POST request is handled as part of the
-F
option.
Booting the system using the secondary firmware image
Method and URI:
POST "https://192.0.2.5/rest/v1/boot?image=secondary"
Example curl command:
$ curl -k -X POST -b /tmp/auth_cookie \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
"https://192.0.2.5/rest/v1/boot?image=secondary"