REST API or your own endpoints?¶
A view reaches Polarion data in two ways. Both are authenticated with the same token from the context, both run as the logged-in user, and most applications use both. This page helps you decide which one to use for a given task; the SDK (context and events) is the third channel and is covered in How an application works.
Side by side¶
| Polarion REST API | Your own endpoints | |
|---|---|---|
| What it is | Polarion's documented API, JSON:API style, under /polarion/rest/v1 | HTTP endpoints under /polarion/apps/<identifier>/rest/, implemented by your JavaScript on the server |
| Code to write | Only in the view | Script on the server plus the call in the view |
| Covers | Projects, work items, documents, test runs, plans, users, enumerations, … | Anything the Polarion Java API can do, plus external systems |
| Request shape | Fixed by the API (sparse fields, includes, pagination) | Defined by you |
| Work per request | One resource or one list | Unlimited (within reason) |
| Runs as | The user | The user |
| Deployed with | Nothing extra | The application package |
| Documentation | REST API User Guide, OpenAPI definition on the server | Your README and TypeScript types |
Use the REST API when…¶
- the data is a single object or a list the API offers directly;
- the operation is a standard create, update, link or comment;
- you want zero server-side code, for example in a prototype or a purely presentational view.
See Calling the REST API from a view and the Cookbook.
Write an endpoint when…¶
- the view would need many requests to assemble its data (trees, cross-project views, per-item computations);
- the logic is a rule or validation that should live in one place and run on the server;
- you need an API that REST does not expose (a utility, a service, history details);
- the operation involves external systems and secrets;
- you want a contract tailored to the UI rather than JSON:API documents;
- the work is heavy and should not run in the browser.
See Your own REST endpoints and Patterns.
Typical split in an application¶
| Task | Channel |
|---|---|
| Show the open work item's fields | REST API |
| Show its full link tree with status of each node | Endpoint |
| Rename, set a field, add a comment | REST API |
| Validate the selected items against project rules | Endpoint |
| Assign all items with a finding to the current user | Endpoint (one call, one result) or REST API (one PATCH per item) |
| Dashboard counts by status, type, assignee | REST API for small projects, endpoint for large ones |
| Notify a chat channel | Endpoint |
What is not available in 2612¶
- No channel from the view back into the host UI: a view cannot refresh the form, open another work item or show a Polarion notification. Navigate with
target="_top"links. - No events other than
selection-changed. - No server push: views poll if they need to observe changes made by others.
These are preview limitations; see Limitations and known issues.