Write data to a z/OS data set or member
You can use this operation to write data to an existing sequential data set, or a member of a partitioned data set (PDS or PDSE). To write to an uncataloged data set, include a volume serial on the request.
HTTP method and URI path
PUT /zosmf/restfiles/ds/[-(<volser>)/]<dataset-name>[(<member-name>)]
- /zosmf/restfiles specifies the z/OS® data set and file REST interface
- /ds indicates a data set request
- -(<volser>) represents a volume serial. For an uncataloged data set, include this parameter to identify the volume to be searched for data sets or members that match the specified <data-set-name> or <member-name>. The length of the volume serial cannot exceed six characters. You cannot use wildcard characters for this parameter. Indirect volume serials are not supported.
- <dataset-name> identifies the data set to which to write. This parameter is required and must consist of a fully qualified data set name. The length of the data set name that you specify on the request cannot exceed 44 characters.
- <member-name> identifies the name of the PDS or PDSE member to
which to write. Include this parameter for a PDS or PDSE member write request.
If the member does not exist, it is created. If the data set name identifies a base name of a Generation Data Group (GDG), then member may refer to relative data sets, for example: (0), (+1), (-1)
- /<data-set-name>: To write to a sequential data set.
- /<data-set-name>(<member-name>): To write to a member of a PDS or PDSE.
- /-(<volser>)/<data-set-name>: To write to an uncataloged sequential data set.
- /-(<volser>)/<data-set-name>(<member-name>): To write to a member of an uncataloged PDS or PDSE.
Request body
The data to write to the target data set. The data is interpreted according to the content-type as one of binary, text, record or 'diff -e' format according a combination of the "Content-Type" and the value of the X-IBM-Data-Type custom header, if present.
Standard headers
- If-Match
- This header is optional; use it to specify
the ETag to be used for correlating this request with a previous request
on the same resource. If the resource has not changed since the ETag
token was generated, the data is written to the target data set or
member. Otherwise, if the resource has been modified, the request
is failed with status code
HTTP 412
.If you omit this header, the data is always written, regardless of whether the resource is changed.
Custom headers
- X-IBM-Data-Type
- This header is optional; use it to indicate whether data conversion is to be performed on the
request body.
- text
- When set to
text
, data conversion is performed. The data transfer process converts each record from the charset specified on the "Content-Type" header of the request. If no charset is specified, the default is ISO8859-1. Each line of data, delimited by a Line Feed in the request charset, is converted to EBCDIC and written as a record to the data set or member. (The line feed character is removed from the data, and the data is padded with the space character to the end of the record if it is a fixed record size data set. For variable record size data sets, the record is written without padding.) If the record size of the data set is smaller than any line of text, an HTTP 400 is returned with a JSON error document indicating that not all data was written.A value
"text;fileEncoding=<codepage>"
can be used to select an alternate EBCDIC code page. The default code page is IBM-1047.A value
text;crlf=true
can be used to control whether each input text line is terminated with a carriage return line feed (CRLF), rather than a line feed (LF), which is the default.A value
text;wrap=true
can be used to support wrapping the data when you write to a F or FB format data set in order to avoid any truncation errors.Note: When set to 'text' and "Content-Type" is "application/x-ibm-diff-e", the input consists of commands in the same format as produced by the z/OS UNIX 'diff -e' command. These commands are used to add, replace and delete lines in the target data set. The following commands are supported:
a
c
d
s/.//
opt : g|<n>, g means global
n means search and replace <n> timesEach command may be optionally preceded by a line or line range, as allowed by the z/OS UNIX 'ed' command. If an error is detected while processing a command,status code 500 is returned with an exception.
- binary
- When set to
binary
, no data conversion is performed. The data is written to the data set without respect to record boundaries. All records will be written at their maximum record length and for fixed length record data sets, the last record will be padded with nulls if required. - record
- When set to
record
, no data conversion is performed. Each logical record is preceded by the 4-byte big endian record length of the record that follows. This length does not include the prefix length. For example: a zero-length record would be 4 bytes of zeros with nothing following.
If you omit this header, the default is
text
; the request body is converted. - X-IBM-Migrated-Recall
-
This header is optional; use it to specify how a migrated data set is handled. By default, a migrated data set is recalled synchronously. The following values may be specified too:
- wait
- This is the default value. If the data set is migrated, wait for it to be recalled before processing the request.
- nowait
- If the data set is migrated, request it to be recalled, but do not wait.
- error
- If the data set is migrated, do not attempt to recall the data set.
- X-IBM-Obtain-ENQ
-
This header is optional; set it to one of the following values to request that a system ENQ be obtained and held after the completion of this request. If not specified, then no ENQs will be held after the completion of this request.
- EXCLU
- a SYSDSN/Exclusive ENQ will be held on the data set
- SHRW
- a SYSDSN/SHR ENQ will be held on the data set, and a SPFEDIT/EXCLU ENQ will be held on the data set, including the member name if this is a request for a PDS member.
- X-IBM-Session-Ref
-
This header is optional; include it with the value returned from a previous X-IBM-Session-Ref response header to indicate that your request should be executed in the TSO address space that was previously reserved with a X-IBM-Obtain-ENQ request header. This address space will not be used for other requests and if not used at least once every 10 minutes it will be terminated.
The following URL request may be used to "ping" the reserved address space to keep it alive:
GET https://zosmf1.yourco.com/zosmf/restfiles/ping HTTP/1.1
X-IBM-Session-Ref: xxxxxxThe X-IBM-Obtain-ENQ and X-IBM-Session-Ref headers are mutually exclusive.
- X-IBM-Release-ENQ
-
This header is optional; it may be specified with a value ''true'' to request that the ENQ held by the associated TSO address space be released.
This header must be specified along with a valid X-IBM-Session-Ref header.
- X-IBM-Dsname-Encoding:
- This header is optional. Use it to indicate your data set and member name codepage. One restriction is that the data set or member name character’s UTF-8 code can be converted to a valid IBM-1047 character.
- X-IBM-Target-System-User
- This 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. BothX-IBM-Target-System-Password
andX-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:- The
X-IBM-Target-System-User
header was provided in a previous request - The service described in Authenticate with a secondary z/OSMF instance was issued in a previous request.
- The
- X-IBM-Target-System-Password
- This 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. BothX-IBM-Target-System-Password
andX-IBM-Target-System-User
must be provided together; otherwise, this header is ignored.
Required authorizations
Request content
Your request must supply the data set content. For an example, see Example request.
Usage considerations
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. Status code 201
indicates success if a new PDS member was
created. Status code 412
indicates that the document does not match the supplied
ETag token on the If-Match header as described above. A status code of
4nn
or 5nn
indicates that an error has occurred. For
more details, see Error handling.
For errors, the HTTP response includes error information as a JSON error report document. See Error report document.
Example request
In Figure 1, notice
that the optional header If-Match is included. This header is specified
with an ETag that was obtained from a previous read request on the
parmlib member. Using an ETag in this manner allows for conditional
processing; the new member contents are written only when the member
has not been modified on the host system since the ETag was generated.
If the member was modified, for example, by another user or process,
this request is failed with HTTP status code 412
.
Example response
- Status code indicating that the request completed (status code
204
) - ETag that you can use on subsequent requests to test for changes to the resource
204 No Content
Etag: DE2BE8B8485EB8F1E28D3716DFFE0680
Content-Type: application/json; charset=UTF-8
Content-Language: en-US
Date: Fri, 07 Nov 2014 02:31:39 GMT
Example request
PUT /zosmf/restfiles/ds/JIAHJ.REST.SRVMP HTTP/1.1
If-Match: B5C6454F783590AA8EC15BD88E29EA42
Content-Type: text/plain; charset=UTF-8
Example response
Example request
PUT /zosmf/restfiles/ds/SYS1.PROCLIB(JH2FPROC) HTTP/1.1
s/a*b/ccc/g