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

Test and debug

2612

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 seeWhere it comes fromWhat to do
success: false, error: "… failed: Error: objectId parameter is required"Your own throw inside try/catchThe 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 objectIdAdd 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 sentSend the parameter or read it through a guarded helper.
error: "… TypeError: arguments.getAsString is not a function"arguments used inside a functionCapture 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 existCheck the javadoc for the class; Java methods are case-sensitive and need parentheses.
success: false, error: "… java.lang.SecurityException …" or a permission messageThe user may not perform the operationExpected for users without rights; show it.
HTTP 400 before any envelopeRequest shape (missing JSON content type or body on POST)Set Content-Type: application/json and send a JSON body, {} if empty.
HTTP 401Missing, invalid or expired X-Polarion-REST-TokenSend the header with a valid token; refresh the context and check that token authentication is enabled. A logged-in browser session is insufficient.
HTTP 404Wrong urlPath, wrong method, or application not installedCompare 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

  1. Edit the script in server-scripts/.
  2. npm run package (the view does not need to change; the script is just copied).
  3. Upload. The new script is active immediately.
  4. 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/catch around 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.