Create a UNIX file or directory

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

HTTP method and URI path

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

Request Body

The request body to create a UNIX file or directory is shown in Request body to create a UNIX file or directory .

Table 1. Request body to create a UNIX file or directory
Field Type Description
type String The request type. This field supports the values: directory or dir to create a directory. The value: file is supported to create a file.
mode String Specifies the file or directory permission bits to be used in creating the file or directory. The characters used to describe permissions are:

r: Permission to read the file

w: Permission to write on the file

x: Permission to execute the file

-: No permission

An example would be: rwxrwxrwx

The nine characters are in three groups of three; they describe the permissions on the file or directory. The first group of 3 describes owner permissions; the second describes group permissions; the third describes other (or world) permissions.

Standard headers

None.

Custom headers

You can include the following custom HTTP headers with this request:
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 201 indicates success. A status code of 4nn or 5nn indicates that an error has occurred. For more details, see Error handling.

For a successful create request, 201 Created is returned.

Example request

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

Request body:

{"type":"file","mode":"RWXRW-RW-"}

Example response

A sample response is shown in Create a UNIX file.
Figure 1. Example: Create a UNIX file
201 Created
Content-Type:  application/json; charset=UTF-8
Content-Length:  0
Date:  Wed, 30 Sep 2015 11:46:21 GMT 

Example request

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

Request body

{"type":"directory","mode":"rwxr-xrwx"}

Example response

A sample response is shown in Create a UNIX directory.
Figure 2. Example: Create a UNIX directory
201 Created
Content-Type:  application/json; charset=UTF-8
Content-Length:  0
Date:  Date:  Wed, 30 Sep 2015 10:50:21 GMT