The chat responses are generated using Generative AI technology for intuitive search and may not be entirely accurate. They are not intended as professional advice. For full details, including our use rights, privacy practices and potential export control restrictions, please refer to our Generative AI Service Privacy Information. As this is a test version, please let us know if something irritating comes up. Like you get recommended a chocolate fudge ice cream instead of an energy managing application. If that occurs, please use the feedback button in our contact form!
Skip to content

Endpoint runtime

2612

This page describes the environment a server script runs in. Observed behavior on Polarion 2612 is stated as fact; details marked as expected should be checked against your server.

Request mapping

GET endpointPOST endpoint
URL/polarion/apps/<identifier>/rest/<urlPath>?a=1&b=2/polarion/apps/<identifier>/rest/<urlPath>
ParametersQuery stringFlat JSON object with string values in the request body; Content-Type: application/json required. Arrays or objects as values are rejected with HTTP 500 (Expected a string but was BEGIN_ARRAY).
Reading a parameterarguments.getAsString('a')arguments.getAsString('a')
AuthenticationValid X-Polarion-REST-Token header required; sessions and cookies do not authenticate endpoint callsSame requirement
Intended forReadsWrites and anything with side effects

A POST without a JSON content type or without a parseable body is expected to be rejected with HTTP 400 before the script runs. Parameters sent in the query string of a POST are not visible to the script.

objectId is mandatory on every call (GET or POST). Without it Polarion answers HTTP 400 Argument objectId is missing in workflow definition before the script runs. Use PROJECT/WI-ID of the object the call concerns, or a project id.

Globals

context

Entry point to the Polarion scripting API.

ExpressionReturns
context.scriptContext()IScriptContext
context.scriptContext().services()IScriptServices: tracker(), security(), project(), …
context.scriptContext().utils()IScriptUtils: httpClient(), …

services().tracker() is ITrackerService, the usual way to reach work items:

const trackerService = context.scriptContext().services().tracker();
const wi = trackerService.getWorkItem(projectId, workItemId);   // IWorkItem
const project = trackerService.getTrackerProject(projectId);    // ITrackerProject

services().security() is ISecurityService; see the javadoc for the accessor of the current user.

arguments

Polarion's IArguments object with the request parameters, available under the name arguments at the top level of the script. Inside a function the name refers to the function's own arguments object, so capture it first: const scriptArguments = arguments;.

MethodDescription
getAsString(name)The parameter as a string. Throws Argument name is missing in workflow definition when the parameter was not sent; the call then fails with HTTP 400. Wrap reads of optional parameters in try/catch.
getAsString(name, default)Variant with a default value, as listed for IArguments in the scripting API; check the javadoc of your version. The examples use a guarded helper instead.
getAsInt(name), getAsBoolean(name), …Typed variants as documented for IArguments in the scripting API.

Structured input must be sent as a JSON-encoded string and parsed with JSON.parse.

Java

GraalVM's interop object. Java.type('fully.qualified.Name') loads a Polarion or JDK class:

const Text = Java.type('com.polarion.core.util.types.Text');
const comment = wi.createComment(Text.plain('Reviewed.'), 'My app', null);

Working with Java objects

  • Java collections (Collection, List) are easiest to iterate after .toArray(); the resulting Java array is indexable with [i] and has .length.
  • Java strings behave like JavaScript strings for comparison and concatenation.
  • null from Java is null in JavaScript; check for it before calling methods (wi.getType() ? wi.getType().getName() : null).
  • Unresolvable objects (for example a work item id that does not exist) are returned as placeholder objects; check isUnresolvable().

Result and envelope

The script's last expression is the result. It must be a plain JavaScript object, array or primitive that can be serialized to JSON. Polarion wraps it:

{ "timestamp": "2026-10-05T10:15:42.945Z", "success": true, "data": <result> }

If the result object contains a non-empty error property, or the script throws, the envelope becomes:

{ "timestamp": "…", "success": false, "error": "<message>" }

A successful script returns HTTP 200. A script that returned { error }, threw, or read a missing parameter returns HTTP 400 with the envelope; a body with non-string values returns HTTP 500. The table below summarizes what was observed on Polarion 2612.

HTTP statusBodyCause
200{ timestamp, success: true, data }Script completed
400{ timestamp, success: false, error }Script returned an error key or threw
400{ error: "Argument objectId is missing in workflow definition." }objectId not sent, or arguments.getAsString() on an absent parameter
500{ error: "… Expected a string but was BEGIN_ARRAY …" }POST body contains an array or object value
401REST error documentMissing, invalid or expired X-Polarion-REST-Token, even if a Polarion session exists
404HTML or error documentUnknown urlPath, wrong method, application not installed

Permissions and transactions

  • The script runs as the user identified by the required REST token. All Polarion permission checks apply.
  • Writes must call save() on the modified or created object: wi.save() for field and assignee changes, comment.save() for a new comment. Several objects can be saved in one script; there is no explicit transaction API.
  • Fields are changed with the setters of IWorkItem, for example wi.setTitle('New title') or wi.setDescription(Text.html('<p>New text</p>')); Text.plain(…) creates plain text. Rich text is not escaped for you. Verified on Polarion 2612 with an endpoint that writes the description.
  • The open work item form does not show a change made by an endpoint until the page is reloaded; a view cannot trigger that reload.
  • Treat GET endpoints as read-only and keep saves in POST endpoints; whether a save in a GET script is rejected was not verified for 2612.

Logging

console.log() output is expected in the Polarion server log. Keep it sparse; the log is shared by the whole server.

Limits

  • A script runs for the duration of the request; long-running scripts keep the caller waiting. Keep work per call small or paginate.
  • There is no state between calls. Cache in the view, or persist in Polarion objects.
  • The script file is read from the uploaded package; re-upload to change it.

Further reading

  • Polarion Scripting Guide in your server's Help (Administrator and User Help → Polarion Scripting Guide).
  • https://<polarion-host>/polarion/sdk/doc/scripting-api/ for IScriptContext, IScriptServices, IArguments.
  • https://<polarion-host>/polarion/sdk/doc/javadoc/ for the Java API (com.polarion.alm.tracker.model.IWorkItem and friends).