Example: Listing a specific subset of the files in a file space

You can query the contents of a file space by submitting an HTTP request containing a query to the WebSphere® MQ Managed File Transfer Web Gateway. The Web Gateway returns a response in XML or JSON format describing only those files in the filespace that match the query.

About this task

You can append a query to your HTTP request that requests information about the files in a file space that match the query. You can query files by their associated details, including the originating user, the transfer start time, the transfer end time, and the transfer ID of the transfer that sent the file to the file space. You can specify the number of results to return.

A successful request returns an HTTP status code of 200 and a payload that describes the files that match the query. You can request that the details of the files are returned in either XML or JSON format. You can write a web application to parse the content of the response and display it in an appropriate format to a web user.

The following steps describe how to submit a request. In this example, the server hosting the WebSphere MQ Managed File Transfer Web Gateway is example.com. The user requesting the information is authorized to access the file space that is being queried. The query requests information that is returned in JSON format, specified by the accept=json query. The query requests a list of files that fulfill the following criteria:
  • The file are in the file space james.
  • The files were sent to the file space by the user bob, specified by the originatoruser=bob query.
  • The files were sent to the file space after 13:00 (UTC) on 26 August 2010, specified by the startafter=2010-08-26T13:00 query.

Procedure

  1. Create an HTTP request with the following format:
    GET HTTP/1.1 /filespace/james/?originatoruser=bob&startafter=2010-08-26T13:00&accept=json
    Host: example.com
    User-Agent: mozilla
    
  2. Submit the request to the Web Gateway. The Web Gateway returns an HTTP response with the following format. In this example, only one file matches the query.
    {
       "fileSpaces" : {
          "fileSpace" : {
             "name" : "james",
             "size" : "1",
             "file" : {
                "transferLink" : "\/wmqfte\/transfer\/
                  414d51205745422e4654452020202020c1a1a34b03720120",
                "fileLink" : "\/wmqfte\/filespace\/james\/
                  414d51205745422e4654452020202020c1a1a34b03720120\/wibble",
                "name" : "\/tmp\/bobs_file.zip",
                "transferID" : "414d51205745422e4654452020202020c1a1a34b03720120",
                "attribute-values" : {
                   "checksum-value" : "98611a272a27d373f92d73a08cf0d4f4",
                   "checksum-method" : "none",
                   "time" : "2010-08-26T14:13:02.000Z",
                   "file-size" : "259354303",
                   "mode" : "text"
                }
             }
          }
       }
    }