Example 3: Read the entire contents of a USS file

In the following example, File Manager Service Provider REST API calls are issued to read all records in a USS file without using a template or copybook.

Initial request

An initial API call to read data from a data resource requires an HTTP Basic Authorization header so that the caller can be authenticated for subsequent access to z/OS® data resources. For example:

Authorization : Basic dXNlcmlkOnBhc3N3b3Jk

where the string after the Basic keyword represents a Base64 encoding of userid:password.

All requests with a JSON payload also require a Content-Type header with a value of application/json.

The initial request also requires the name of the data resource.

This request will attempt to read the entire contents of the USS file filemanager.properties in directory /var/filemanager.

{
    "resource" : 
    {
        "resourceName" : "/var/filemanager/filemanager.properties"
    },
    "operation" :
    {
        "numRecords" : 10000
    }
}

No field mapping in the response will occur because no template parameters are provided. In addition, no session will be maintained because session is not specified and the default is false.

10,000 is the maximum number of records that can be read by a single request. If the file contains more than 10,000 records, a session would be required to read the records in blocks.

Successful response

A successful response (HTTP Status Code 200) will be similar to the following:

{
   "records" : 
   [
      {
         "layouts" : 
         [
            {
               "layout": "UNKNOWN",
               "fields":
               [
                  {
                     "field": "DATA",
                     "type": "AN",
                     "value": "com.ibm.websphere.productId=filemanager"
                  }
               ]
            }
         ]
      },
      {
         "last" : true, 
         "layouts" : 
         [
            {
               "layout": "UNKNOWN",
               "fields":
               [
                  {
                     "field": "DATA",
                     "type": "AN",
                     "value": "com.ibm.websphere.productInstall=/var/filemanager"
                  }
               ]
            }
         ]
      }
   ]
}

The caller does not need to issue a second request to terminate the File Manager session because no session was maintained by the service provider. Because the second record returned is the last in the file, last is set to true.