Test and debug¶
Endpoints are plain HTTP. Every test request must include a valid X-Polarion-REST-Token header; a browser session alone does not authenticate the request.
Call a GET endpoint from the developer tools¶
With an application view open in Polarion, select the view's frame in the browser console. Use the context fetched by your view to set the token header:
const params = new URLSearchParams({ objectId: 'test/TEST-514', depth: '1' });
const r = await fetch(`${ctx.appEndpoint}/linked-tree?${params}`, {
headers: { 'X-Polarion-REST-Token': ctx.restToken, Accept: 'application/json' },
});
console.log(await r.json());
ctx is the context your view fetched. Opening the URL directly in a new tab does not send this header and cannot authenticate the request. An authenticated call returns the raw envelope:
{"timestamp":"2026-10-05T10:15:42.945Z","success":true,"data":{"item":{…}}}
Call any endpoint from the developer tools¶
With a view open in Polarion, the context is in memory. In the browser console, select the view's frame and run:
const r = await fetch(`${ctx.appEndpoint}/validate`, {
method: 'POST',
headers: { 'X-Polarion-REST-Token': ctx.restToken, 'Content-Type': 'application/json' },
body: JSON.stringify({ objectId: 'test/TEST-514', objectIds: JSON.stringify(['test/TEST-514']) }),
});
console.log(await r.json());
ctx is the context your view fetched; expose it on window in development builds if that is convenient.
Call from an HTTP client with a REST token¶
For a diagnostic call with curl, supply a current REST token as POLARION_REST_TOKEN in your local shell. Use the token provided to the view as context.restToken; keep it out of saved scripts, logs and version control:
curl -s -X POST "https://<host>/polarion/apps/com.example.releasechecklist/rest/validate" \
-H "X-Polarion-REST-Token: $POLARION_REST_TOKEN" \
-H "Content-Type: application/json" \
-d '{"objectId":"test/TEST-514","objectIds":"[\"test/TEST-514\"]"}'
Application endpoints require this header. A session cookie or an Authorization: Bearer personal access token does not replace it. Do not assume that authentication methods supported by the standard REST API also authenticate application endpoints.
Reading errors¶
| What you see | Where it comes from | What to do |
|---|---|---|
success: false, error: "… failed: Error: objectId parameter is required" | Your own throw inside try/catch | The view did not send the parameter, or sent it in the wrong place (query string vs body). |
HTTP 400, error: "Argument objectId is missing in workflow definition." | The call did not include objectId | Add objectId=PROJECT/WI-ID to every call. |
HTTP 400, error: "… Argument role is missing in workflow definition." | arguments.getAsString() for a parameter that was not sent | Send the parameter or read it through a guarded helper. |
error: "… TypeError: arguments.getAsString is not a function" | arguments used inside a function | Capture const scriptArguments = arguments; at the top of the script. |
success: false, error: "… TypeError: wi.getFoo is not a function" | A Java method name that does not exist | Check the javadoc for the class; Java methods are case-sensitive and need parentheses. |
success: false, error: "… java.lang.SecurityException …" or a permission message | The user may not perform the operation | Expected for users without rights; show it. |
| HTTP 400 before any envelope | Request shape (missing JSON content type or body on POST) | Set Content-Type: application/json and send a JSON body, {} if empty. |
| HTTP 401 | Missing, invalid or expired X-Polarion-REST-Token | Send the header with a valid token; refresh the context and check that token authentication is enabled. A logged-in browser session is insufficient. |
| HTTP 404 | Wrong urlPath, wrong method, or application not installed | Compare with the manifest and Properties. |
The server log¶
Uncaught exceptions and the output of console.log() in scripts are expected in Polarion's main log (data/logs/main/log4j-*.log). Prefix log lines with the application identifier so that they can be filtered.
Iterating on a script¶
- Edit the script in
server-scripts/. npm run package(the view does not need to change; the script is just copied).- Upload. The new script is active immediately.
- Repeat the call.
For faster iteration on logic that does not depend on request parameters, the Scripting topic in Global Administration can run GraalVM scripts interactively against the same services; move the code into the endpoint once it works.
Checklist before shipping an endpoint¶
- Every parameter validated; helpful messages for missing ones.
-
try/catcharound the body; errors include the endpoint name. - No writes in GET endpoints.
- Result mapped to plain data; no Java objects.
- Contract (request, response) documented in the README and typed in
src/types.ts. - Tested as a user without administrator rights.