Upload File to Server REST Service

Use Upload File to Server REST Service to upload a specific file such as a client certificate, backup file, or archive file, to the IBM® Security Guardium® Key Lifecycle Manager server. Only files with the following file extensions can be uploaded: cer, der, p12, exp, jar.

Operation
POST
URL
https://host:port/SKLM/rest/v1/filetransfer/upload/objectfiles
By default, Guardium Key Lifecycle Manager server listens to non-secure port 9080 (HTTP) and secure port 9443 (HTTPS) for communication. During IBM Security Guardium Key Lifecycle Manager installation, you can modify these default ports.
Note: The non-secure port 9080 is not applicable when IBM Security Guardium Key Lifecycle Manager is deployed in a containerized environment.

Request

Request Parameters
Parameter Description
host Specify the IP address or host name of the IBM Security Guardium Key Lifecycle Manager server.
port Specify the port number on which the IBM Security Guardium Key Lifecycle Manager server listens for requests.
Form parameters
Property name Description
fileToUpload Required. Specify the name of the file that you want to upload to the IBM Security Guardium Key Lifecycle Manager server. If a file of the same name already exists in the destination directory, then the file will not be uploaded.
destination Optional. Specify the complete or absolute path of the directory on the IBM Security Guardium Key Lifecycle Manager server to which you want to upload the file. By default, the file is uploaded to the SKLM_DATA directory.
overwrite Use this parameter to overwrite an existing file on the IBM Security Guardium Key Lifecycle Manager server.

By default, the overwrite parameter is set to no. If set to yes, the file (if exists) is replaced with the file specified in the fileToUpload parameter.

Request Headers
Header name Value
Content-Type application/octet-stream
Accept application/json
Authorization SKLMAuth userAuthId=<authIdValue>
Accept-Language Any valid locale that is supported by IBM Security Guardium Key Lifecycle Manager. For example: en or de

Response

Response Headers
Header name Value and description
Status Code
200 OK
The request was successful. The response body contains the requested representation.
400® Bad Request
The authentication information was not provided in the correct format.
401 Unauthorized
The authentication credentials were missing or incorrect.
404 Not Found Error
The processing of the request fails.
500 Internal Server Error
The processing of the request fails because of an unexpected condition on the server.
Content-Type application/json
Content-Language Locale for the response message.
Success Response Body

JSON object with the following specification.

JSON property name Description
code Returns the application success code.
messageId Returns the status message identifier.
status Returns a success message.
Error Response Body

JSON object with the following specification.

JSON property name Description
code Returns the application error code.
messageId Returns the status message identifier.
status Returns a message that describes the error.

Example

Upload a server certificate
POST https://localhost:port/SKLM/rest/v1/filetransfer/upload/objectfiles
Content-Type: multipart/form-data; boundary=BoundaryString
Authorization: SKLMAuth userAuthId=139aeh34567m

--BoundaryString
Content-Disposition: form-data; name="fileToUpload"; filename="server.cer"

<File Content>
--BoundaryString
Content-Disposition: form-data; name="overwrite"

yes
--BoundaryString--
Success response
{
    "code": "0",
    "status": "CTGKM3465I File /opt/IBM/WebSphere/Liberty/products/sklm/data/server.cer uploaded successfully.",
    "messageId": "CTGKM3465I"
}
Invalid service request where the user is trying to upload a file that already exists and overwrite is set to no
curl -X 'POST' \
  'https://9.157.215.28:9443/SKLM/rest/v1/filetransfer/upload/objectfiles' \
  -H 'accept: application/json' \
  -H 'Accept-Language: en' \
  -H 'Authorization: SKLMAuth userAuthId=b08e1187-6ceb-45bc-8cdf-47c20a973039' \
  -H 'Content-Type: multipart/form-data' \
  -F 'fileToUpload=@cert1_admin_1636341955632.cer;type=text/html' \
  -F 'destination=' \
  -F 'overwrite=no'
Error response
{
  "code": "1",
  "messageId": "CTGKM3466E",
  "status": "CTGKM3466E Cannot upload the file cert1_admin_1636341955632.cer because a file with the same name already exists on the server."
}
Table 1. Topic change log
Date Change description
21 April 2023 Corrected the REST example.
09 Nov 2021 Added the definition of the overwrite parameter.
08 Dec 2020 Initial version.