Product Documentation

Performing File Operations

Sep 01, 2016

NetScaler operations such as configuring SSL certificates requires the input files to be available locally on the NetScaler appliance. NITRO allows you to perform file operations such as uploading files, retrieving files, retrieving file content, and deleting files of types: txt, cert, req, xml, lic, and key.

Note:
  • File size must be less than or equal to 2 MB.
  • Use the "BASE64" value for the fileencoding attribute in the request payload. This is the only valid encoding currently supported.
  • The filelocation path must be URL encoded. For example, if the path is /nsconfig/ssl, encode the / and use the file location as %2Fnsconfig%2Fssl.
  • When uploading a file, make sure that each directory of the file path has the 755 (read, write, execute) permission. For example, to upload a file to the "/nsconfig/ssl/" directory, the following directories must have the 755 permission:
    • flash (because the "/nsconfig" folder is actually a link to "/flash/nsconfig/" directory)
    • nsconfig
    • ssl

Uploading a File

To upload a file to the NetScaler, specify a name for the file, the location where the file must be created on the NetScaler, and the content of the file.

For example, to upload a file named cert1.crt in the /nsconfig/ssl/ directory:

  • Request:

    HTTP Method
    POST
    URL
    http://<netscaler-ip-address>/nitro/v1/config/systemfile
    Request Headers
    Cookie:NITRO_AUTH_TOKEN=<tokenvalue> 
    Content-Type:application/json
    
    Request Payload
    { 
        "systemfile": 
        { 
            "filename": "cert1.crt", 
            "filelocation": "/nsconfig/ssl/",        
            "filecontent":"VGhpcyBpcyBteSBmaWxl", 
            "fileencoding": "BASE64" 
        } 
    }
    
  • Response:

    HTTP Status Code on Success
    200 OK
    HTTP Status Code on Failure
    4xx <string> (for general HTTP errors) or 5xx <string> (for NetScaler-specific errors). The response payload provides details of the error.

Retrieving the Files

To retrieve the files from a specific NetScaler directory, specify the directory path in the URL.

For example, to retrieve the files from the /nsconfig/ssl directory.

  • Request:

    HTTP Method
    GET
    URL
    http://<netscaler-ip-address>/nitro/v1/config/systemfile?args=filelocation:%2Fnsconfig%2Fssl
    Request Header
    Cookie:NITRO_AUTH_TOKEN=<tokenvalue>
    
    Accept:application/json
    
  • Response:

    HTTP Status Code on Success
    200 OK
    HTTP Status Code on Failure
    4xx <string> (for general HTTP errors) or 5xx <string> (for NetScaler-specific errors). The response payload provides details of the error.
    Response Header
    Content-Type:application/json
    
    Response Payload
    { 
        "systemfile":  
        [  
            {  
                "filename": "ns-root.key",  
                "filelocation": "/nsconfig/ssl",  
                "fileaccesstime": "Tue Jan 14 19:27:01 2014",  
                "filemodifiedtime": "Tue Nov  5 17:16:00 2013" 
            },  
            { 
                "filename": "ns-root.req",  
                "filelocation": "/nsconfig/ssl",  
                "fileaccesstime": "Tue Jan 14 19:27:01 2014",  
                "filemodifiedtime": "Tue Nov  5 17:16:00 2013"  
            } 
        ] 
    } 
    

Retrieving Contents of a Specific File

To retrieve the contents of a file, specify the filename and its directory path in the URL.

For example, to retrieve the contents of the ns-root.key file from the /nsconfig/ssl directory.

  • Request:

    HTTP Method
    GET
    URL
    http://<netscaler-ip-address>/nitro/v1/config/systemfile/ns-root.key?args=filelocation:%2Fnsconfig%2Fssl
    Request Header
    Cookie:NITRO_AUTH_TOKEN=<tokenvalue>
    
    Accept:application/json
    
  • Response:

    HTTP Status Code on Success
    200 OK
    HTTP Status Code on Failure
    4xx <string> (for general HTTP errors) or 5xx <string> (for NetScaler-specific errors). The response payload provides details of the error.
    Response Header
    Content-Type:application/json
    
    Response Payload
    { 
        "systemfile":  
        [  
            {  
                "filename": "ns-root.key",  
                "filelocation": "/nsconfig/ssl",  
                "filecontent": "LS0tLS1CRUdJTiBSU0EgUFJJVkFU0tLQo=",  
                "fileencoding": "BASE64",  
                "fileaccesstime": "Tue Jan 14 19:27:01 2014",  
                "filemodifiedtime": "Tue Nov  5 17:16:00 2013"  
            }  
        ]  
    }
    

Deleting a File

To delete a file from the NetScaler appliance, specify the filename and the directory path in the URL.

For example, to delete the ns-root.key file from the /nsconfig/ssl directory.

  • Request:

    HTTP Method
    DELETE
    URL
    https://<netscaler-ip-address>/nitro/v1/config/systemfile/ns-root.key?args=filelocation:%2Fnsconfig%2Fssl
    Request Header
    Cookie:NITRO_AUTH_TOKEN=<tokenvalue>
    
  • Response:

    HTTP Status Code on Success
    200 OK
    HTTP Status Code on Failure
    4xx <string> (for general HTTP errors) or 5xx <string> (for NetScaler-specific errors). The response payload provides details of the error.