---
title: "Task request"
source: https://dev.pageseeder.com/guide/publishing/ant_api/tasks/task_request.html
last_updated: 2026-08-07T17:09:54+10:00
tokens: ~1760
---

# Task request

Allows Ant scripts to make one or more HTTP requests to PageSeeder and write the responses to a file or multiple files.

> **Note:** If an HTTP code 202 is returned, the request is treated as an Asynchronous process by polling PageSeeder until the process is finished and then returning the final thread XML as the response.

## Definition

```xml
<ps:request
    path="[request path]"
    method="[method]"
    output="[output]"
    failonerror="[true|false]"
    parseids="[element name]"
    pollinginterval="[milliseconds]"
    config="[config name]">
  <parameter name="[param name]"
             value="[param value]"/>
      or
  <fileset dir="[requests directory]"
           includes="[request.xml]" />
</ps:request>
```

## Attributes

| **Attribute** | Description | Required | Default |
| --- | --- | --- | --- |
| **path** | The path for the request after the `/ps` site prefix (e.g. `/api/groups/mygroup`) | Yes, unless specified in request XML files |  |
| **output** | Specifies the path of the file to write the response to (e.g. `output.xml`) | Yes |  |
| **method** | Specifies the HTTP method for the request | No | `GET` |
| **failonerror** | If `true`, stop ANT build script on error | No | `true` |
| **errorloglevel** | The level that response errors are logged as (`debug\|verbose\|info\|warn\|error`).* Requires PageSeeder v6.2006 or higher.* | No | `error` |
| **parseids** | Name of element to parse `id` attribute of in XML response and set in ANT property `ps.response.ids` as comma-separated list. *Requires PageSeeder v6.3 or higher.* | No |  |
| **pollinginterval** | The number of milliseconds between each check to see if an  Asynchronous process is complete (**must not **be more than `60000`). | No | `2000` |
| **config** | Universal PS config name | No | `default` |

> **Note:** If the ANT script is run inside PageSeeder always use `${ps.config.default.user.id}` instead of `${ps.config.default.username}` in the **path** in case the user hasn’t specified a username (for example `/api/members/${ps.config.default.user.id}/comments/forurl` ).

## Elements

### Element \<parameter\>

If specified set the parameters for the request.

| **Attribute** | Description | Required |
| --- | --- | --- |
| **name** | The parameter name | Yes |
| **value** | The parameter value | Yes |

### Element \<body\>

If specified set the request body for `method="PUT"`.

| **Attribute** | Description | Required |
| --- | --- | --- |
| **value** | The body value | Yes |

### Element \<fileset\>

The standard ANT [fileset](https://ant.apache.org/manual/Types/fileset.html) element can be used to specify one or more request XML files that contain details of the requests.

## Request XML files

Request XML files can be used to override any `path`, `method`, `output` or `<parameter>` defined by the `<ps:request>` and perform multiple requests—one for each file.

A Request File is a UTF-8-encoded XML document that expresses the parameters for a single request in the following syntax where `<parameter>`, `<body>` and the attributes are optional:

```xml

<request [path="[request path]"]
         [method="[method]"]
         [output="[output]"] >
  <parameter name="x" [type="[text|xml]"]>a</parameter>
  <parameter name="y" [type="[text|xml]"]>b</parameter>
  <body [type="[text|xml]"]>c</body>
</request>
```

- `type="text"`: means unescape content when sending (e.g. “x &gt; 1” is sent as “x \> 1”)—this is the default if `type` is not specified.
- `type="xml"`: means send content as XML (for example, “\<para\>x &gt; 1\</para\>” is sent as is).

Processed in alphabetical path order, each Request that does not specify an `output` has a response written to the main output file as follows:

```xml

<responses>
  <response filepath="z/d.xml"> ... </response>
  <response filepath="z/e.xml"> ... </response>
</responses>
```

## Environment

This task uses the following [ps:config](task_config.md) environment properties:

- **scheme** – scheme for connecting to PageSeeder.
- **host** – host for connecting to PageSeeder.
- **port** – port for connecting to PageSeeder.
- **site.prefix** – site prefix for connecting to PageSeeder – default  /ps.
- **user.token** or **jsessionid** or **username/password** – access token or jsessionid or  username/password for connecting to PageSeeder.

## Example scripts

### Validate all documents in a folder

This script starts a validation thread on a folder and waits until it finishes, then downloads the validation report. **It includes properties for running inside PageSeeder and the /api prefix requires v6.**

```xml
<property name="working" value="${ps.config.default.working}" />
<property name="member"  value="${ps.config.default.user.id}" />
<property name="group"   value="${ps.config.default.group.name}" />
<property name="folder"  value="${ps.config.default.uri.id}" />

<ps:request output="${working}/output.xml"
    path="/api/members/${member}/groups/${group}/uris/${folder}/foldervalidate"
    method="POST">
  <parameter name="schema" value="default.sch"/>
</ps:request>
<ps:request output="${working}/validation.xml"
    path="/validation-report/"
    method="GET">
  <parameter name="group" value="${group}"/>
</ps:request>
```

The `8` in `/uris/8` is the URI ID of the folder.

### Create multiple comments

```xml
<ps:request output="output.xml"
    path="/api/members/456/comments/forurl"
    method="POST">
  <fileset dir="c:\input\comments">
    <include name="*.*"/>
  </fileset>
</ps:request>
```

The `456` in `/members/456` is the requesting member’s ID (you can also use their username if they have one).

Files in `c:\input\comments`:

**request1.xml**

```xml
<?xml version="1.0" encoding="utf-8" ?>
<request>
  <parameter name="url">http://www.weborganic.com/</parameter>
  <parameter name="title">My Comment</parameter>
  <parameter name="groups">test-mygroup</parameter>
  <parameter name="content">Hello world!</parameter>
  <parameter name="authorname">John Jones</parameter>
</request>
```

**request2.xml**

```xml
<?xml version="1.0" encoding="utf-8" ?>
<request>
  <parameter name="url">http://www.mysite.com/</parameter>
  <parameter name="title">My Comment 2</parameter>
  <parameter name="groups">test-mygroup</parameter>
  <parameter name="content">Hello again world!</parameter>
  <parameter name="authorname">John Jones</parameter>
</request>
```

### Get edit history for multiple documents

```xml

<ps:request output="output.xml">
  <fileset dir="c:\input\history">
    <include name="*.*"/>
  </fileset>
</ps:request>
```

Files in `c:\input\history`:

The `123` in `/uris/123` is the URI ID of the document.

**request1.xml**

```xml

<?xml version="1.0" encoding="utf-8" ?>
<request path="/service/groups/test-mygroup/uris/123/history">
  <parameter name="events">edit</parameter>
</request>
```

**request2.xml**

```xml

<?xml version="1.0" encoding="utf-8" ?>
<request path="/service/groups/test-mygroup/uris/456/history">
  <parameter name="events">edit</parameter>
</request>
```

