Delete a UNIX file or directory

You can use this operation to delete a UNIX file or directory.

HTTP method and URI path

DELETE /zosmf/restfiles/fs/<file-pathname>
where:
  • /zosmf/restfiles specifies the z/OS® data set and file REST interface
  • /fs indicates a UNIX file or directory.
  • <file-pathname> is the name of the file or directory you are going to delete.

Request Body

None.

Standard headers

None.

Custom headers

X-IBM-Option:An optional parameter for deleting a directory. If it is not specified, only the empty directory can be deleted. If it is specified as recursive, it means all the files and sub-directories will be deleted.

Start of changeX-IBM-Target-System = <string>End of change
Start of changeThis header indicates the target system name (nick name) for this request, where the system name (nick name) is defined in the local system Systems table. The target host system must support single-sign-on by using either an LTPA token or a valid X-IBM-Target-System-User and X-IBM-Target-System-Password is provided for the target system. If the target system is the local system, this header is ignored and has no effect.End of change
Start of changeX-IBM-Target-System-UserEnd of change
Start of changeThis header indicates the z/OS user ID that allows the user to access the target system. If the X-IBM-Target-System header is not supplied, this header is ignored. Both X-IBM-Target-System-Password and X-IBM-Target-System-User must be provided together; otherwise, this header is ignored.
If this header is not provided in the current request, the current request uses the authenticated user credentials to access the target system if either of the following conditions are true:
End of change
Start of changeX-IBM-Target-System-PasswordEnd of change
Start of changeThis header indicates the password that is associated with the z/OS user ID. If the X-IBM-Target-System header is not supplied, this header is ignored. Both X-IBM-Target-System-Password and X-IBM-Target-System-User must be provided together; otherwise, this header is ignored.End of change

Query parameters

None.

Content type

The content type is application/json.

Required authorizations

See Required authorizations.

Usage considerations

See Usage considerations for the z/OSMF REST services.

Expected response

On completion, the service returns an HTTP response, which includes a status code indicating whether your request completed. Status code 204 indicates success. A status code of 4nn or 5nn indicates that an error has occurred. For more details, see Error handling.

If the request is successfully executed, status code 204 indicates success and no content returned is returned.

Example request

In the following example, the DELETE method is used to delete a UNIX file.
DELETE /zosmf/restfiles/fs/u/jiahj/text.txt HTTP/1.1

Example response

A sample response is shown in Figure 1.
Figure 1. Example: Delete a UNIX file
204 No Content
Content-Type:  application/json; charset=UTF-8
Content-Length:  0
Date:  Wed, 16 Sep 2015 12:10:22 GMT 

Example request

The DELETE method is used to delete a UNIX directory.
DELETE /zosmf/restfiles/fs/u/jiahj/testDir HTTP/1.1

Example response

A sample response is shown in Delete a UNIX directory.
Figure 2. Example: Delete a UNIX directory
204 No Content
Content-Type:  application/json; charset=UTF-8
Content-Length:  0
Date:  Wed, 16 Sep 2015 12:15:22 GMT