Polarion REST API

DocumentAttachments

getDocumentAttachment

Returns the specified Document Attachment.

/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}

Usage and Code Samples

curl -X GET "https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}?fields[categories]={fields[categories]}&fields[document_attachments]={fields[document_attachments]}&fields[document_comments]={fields[document_comments]}&fields[document_parts]={fields[document_parts]}&fields[documents]={fields[documents]}&fields[enumerations]={fields[enumerations]}&fields[externallylinkedworkitems]={fields[externallylinkedworkitems]}&fields[featureselections]={fields[featureselections]}&fields[globalroles]={fields[globalroles]}&fields[icons]={fields[icons]}&fields[jobs]={fields[jobs]}&fields[linkedoslcresources]={fields[linkedoslcresources]}&fields[linkedworkitems]={fields[linkedworkitems]}&fields[page_attachments]={fields[page_attachments]}&fields[pages]={fields[pages]}&fields[plans]={fields[plans]}&fields[projectroles]={fields[projectroles]}&fields[projects]={fields[projects]}&fields[projecttemplates]={fields[projecttemplates]}&fields[revisions]={fields[revisions]}&fields[testparameter_definitions]={fields[testparameter_definitions]}&fields[testparameters]={fields[testparameters]}&fields[testrecord_attachments]={fields[testrecord_attachments]}&fields[testrecords]={fields[testrecords]}&fields[testrun_attachments]={fields[testrun_attachments]}&fields[testrun_comments]={fields[testrun_comments]}&fields[testruns]={fields[testruns]}&fields[teststep_results]={fields[teststep_results]}&fields[teststepresult_attachments]={fields[teststepresult_attachments]}&fields[teststeps]={fields[teststeps]}&fields[usergroups]={fields[usergroups]}&fields[users]={fields[users]}&fields[workitem_approvals]={fields[workitem_approvals]}&fields[workitem_attachments]={fields[workitem_attachments]}&fields[workitem_comments]={fields[workitem_comments]}&fields[workitems]={fields[workitems]}&fields[workrecords]={fields[workrecords]}&include={include}&revision={revision}" -H  "Authorization: Bearer {personal_access_token}" -H  "Accept: application/json"
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class DocumentAttachmentsApiExample {

    public static void main(String[] args) throws IOException, InterruptedException { 
        String polarionToken = "{personal_access_token}";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}?fields[categories]={fields[categories]}&fields[document_attachments]={fields[document_attachments]}&fields[document_comments]={fields[document_comments]}&fields[document_parts]={fields[document_parts]}&fields[documents]={fields[documents]}&fields[enumerations]={fields[enumerations]}&fields[externallylinkedworkitems]={fields[externallylinkedworkitems]}&fields[featureselections]={fields[featureselections]}&fields[globalroles]={fields[globalroles]}&fields[icons]={fields[icons]}&fields[jobs]={fields[jobs]}&fields[linkedoslcresources]={fields[linkedoslcresources]}&fields[linkedworkitems]={fields[linkedworkitems]}&fields[page_attachments]={fields[page_attachments]}&fields[pages]={fields[pages]}&fields[plans]={fields[plans]}&fields[projectroles]={fields[projectroles]}&fields[projects]={fields[projects]}&fields[projecttemplates]={fields[projecttemplates]}&fields[revisions]={fields[revisions]}&fields[testparameter_definitions]={fields[testparameter_definitions]}&fields[testparameters]={fields[testparameters]}&fields[testrecord_attachments]={fields[testrecord_attachments]}&fields[testrecords]={fields[testrecords]}&fields[testrun_attachments]={fields[testrun_attachments]}&fields[testrun_comments]={fields[testrun_comments]}&fields[testruns]={fields[testruns]}&fields[teststep_results]={fields[teststep_results]}&fields[teststepresult_attachments]={fields[teststepresult_attachments]}&fields[teststeps]={fields[teststeps]}&fields[usergroups]={fields[usergroups]}&fields[users]={fields[users]}&fields[workitem_approvals]={fields[workitem_approvals]}&fields[workitem_attachments]={fields[workitem_attachments]}&fields[workitem_comments]={fields[workitem_comments]}&fields[workitems]={fields[workitems]}&fields[workrecords]={fields[workrecords]}&include={include}&revision={revision}"))
                .header("Accept", "application/json")
                .header("Authorization", "Bearer " + polarionToken)
                .GET()
                .build();

        HttpClient client = HttpClient.newHttpClient();
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response);
    }
}
const options = {
    method: 'GET',
    headers: { 
        'Authorization': 'Bearer {personal_access_token}',
        'Accept': 'application/json'
    }
}

fetch('https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}?fields[categories]={fields[categories]}&fields[document_attachments]={fields[document_attachments]}&fields[document_comments]={fields[document_comments]}&fields[document_parts]={fields[document_parts]}&fields[documents]={fields[documents]}&fields[enumerations]={fields[enumerations]}&fields[externallylinkedworkitems]={fields[externallylinkedworkitems]}&fields[featureselections]={fields[featureselections]}&fields[globalroles]={fields[globalroles]}&fields[icons]={fields[icons]}&fields[jobs]={fields[jobs]}&fields[linkedoslcresources]={fields[linkedoslcresources]}&fields[linkedworkitems]={fields[linkedworkitems]}&fields[page_attachments]={fields[page_attachments]}&fields[pages]={fields[pages]}&fields[plans]={fields[plans]}&fields[projectroles]={fields[projectroles]}&fields[projects]={fields[projects]}&fields[projecttemplates]={fields[projecttemplates]}&fields[revisions]={fields[revisions]}&fields[testparameter_definitions]={fields[testparameter_definitions]}&fields[testparameters]={fields[testparameters]}&fields[testrecord_attachments]={fields[testrecord_attachments]}&fields[testrecords]={fields[testrecords]}&fields[testrun_attachments]={fields[testrun_attachments]}&fields[testrun_comments]={fields[testrun_comments]}&fields[testruns]={fields[testruns]}&fields[teststep_results]={fields[teststep_results]}&fields[teststepresult_attachments]={fields[teststepresult_attachments]}&fields[teststeps]={fields[teststeps]}&fields[usergroups]={fields[usergroups]}&fields[users]={fields[users]}&fields[workitem_approvals]={fields[workitem_approvals]}&fields[workitem_attachments]={fields[workitem_attachments]}&fields[workitem_comments]={fields[workitem_comments]}&fields[workitems]={fields[workitems]}&fields[workrecords]={fields[workrecords]}&include={include}&revision={revision}', options)
    .then(response => console.log(response))
    .catch(error => console.log('error', error));
var client = new RestClient("https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}?fields[categories]={fields[categories]}&fields[document_attachments]={fields[document_attachments]}&fields[document_comments]={fields[document_comments]}&fields[document_parts]={fields[document_parts]}&fields[documents]={fields[documents]}&fields[enumerations]={fields[enumerations]}&fields[externallylinkedworkitems]={fields[externallylinkedworkitems]}&fields[featureselections]={fields[featureselections]}&fields[globalroles]={fields[globalroles]}&fields[icons]={fields[icons]}&fields[jobs]={fields[jobs]}&fields[linkedoslcresources]={fields[linkedoslcresources]}&fields[linkedworkitems]={fields[linkedworkitems]}&fields[page_attachments]={fields[page_attachments]}&fields[pages]={fields[pages]}&fields[plans]={fields[plans]}&fields[projectroles]={fields[projectroles]}&fields[projects]={fields[projects]}&fields[projecttemplates]={fields[projecttemplates]}&fields[revisions]={fields[revisions]}&fields[testparameter_definitions]={fields[testparameter_definitions]}&fields[testparameters]={fields[testparameters]}&fields[testrecord_attachments]={fields[testrecord_attachments]}&fields[testrecords]={fields[testrecords]}&fields[testrun_attachments]={fields[testrun_attachments]}&fields[testrun_comments]={fields[testrun_comments]}&fields[testruns]={fields[testruns]}&fields[teststep_results]={fields[teststep_results]}&fields[teststepresult_attachments]={fields[teststepresult_attachments]}&fields[teststeps]={fields[teststeps]}&fields[usergroups]={fields[usergroups]}&fields[users]={fields[users]}&fields[workitem_approvals]={fields[workitem_approvals]}&fields[workitem_attachments]={fields[workitem_attachments]}&fields[workitem_comments]={fields[workitem_comments]}&fields[workitems]={fields[workitems]}&fields[workrecords]={fields[workrecords]}&include={include}&revision={revision}");
client.Timeout = -1;
var request = new RestRequest();
request.Method = Method.GET;
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer {personal_access_token}");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Parameters

Path parameters
Name Description
projectId*
String
The Project ID.
Required
spaceId*
String
The Space ID. (Use '_default' without quotes to address the default Space.)
Required
documentName*
String
The Document name.
Required
attachmentId*
String
The Attachment ID.
Required
Query parameters
Name Description
fields[categories]
String
fields[document_attachments]
String
fields[document_comments]
String
fields[document_parts]
String
fields[documents]
String
fields[enumerations]
String
fields[externallylinkedworkitems]
String
fields[featureselections]
String
fields[globalroles]
String
fields[icons]
String
fields[jobs]
String
fields[linkedoslcresources]
String
fields[linkedworkitems]
String
fields[page_attachments]
String
fields[pages]
String
fields[plans]
String
fields[projectroles]
String
fields[projects]
String
fields[projecttemplates]
String
fields[revisions]
String
fields[testparameter_definitions]
String
fields[testparameters]
String
fields[testrecord_attachments]
String
fields[testrecords]
String
fields[testrun_attachments]
String
fields[testrun_comments]
String
fields[testruns]
String
fields[teststep_results]
String
fields[teststepresult_attachments]
String
fields[teststeps]
String
fields[usergroups]
String
fields[users]
String
fields[workitem_approvals]
String
fields[workitem_attachments]
String
fields[workitem_comments]
String
fields[workitems]
String
fields[workrecords]
String
include
String
Include related entities. See REST API User Guide for details.
revision
String
The revision ID.

Responses

Status: 200 - OK

Status: 400 - Bad Request

Status: 401 - Unauthorized

Status: 403 - Forbidden

Status: 404 - Not Found

Status: 406 - Not Acceptable

Status: 4XX-5XX - Error responses have the following structure:

Status: 500 - Internal Server Error

Status: 503 - Service Unavailable


getDocumentAttachmentContent

Downloads the file content for a specified Document Attachment.

/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}/content

Usage and Code Samples

curl -X GET "https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}/content?revision={revision}" -H  "Authorization: Bearer {personal_access_token}" -H  "Accept: application/octet-stream, application/json"
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class DocumentAttachmentsApiExample {

    public static void main(String[] args) throws IOException, InterruptedException { 
        String polarionToken = "{personal_access_token}";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}/content?revision={revision}"))
                .header("Accept", "application/octet-stream, application/json")
                .header("Authorization", "Bearer " + polarionToken)
                .GET()
                .build();

        HttpClient client = HttpClient.newHttpClient();
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response);
    }
}
const options = {
    method: 'GET',
    headers: { 
        'Authorization': 'Bearer {personal_access_token}',
        'Accept': 'application/octet-stream, application/json'
    }
}

fetch('https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}/content?revision={revision}', options)
    .then(response => console.log(response))
    .catch(error => console.log('error', error));
var client = new RestClient("https://example.com/polarion/rest/v1/projects/{projectId}/spaces/{spaceId}/documents/{documentName}/attachments/{attachmentId}/content?revision={revision}");
client.Timeout = -1;
var request = new RestRequest();
request.Method = Method.GET;
request.AddHeader("Accept", "application/octet-stream, application/json");
request.AddHeader("Authorization", "Bearer {personal_access_token}");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Parameters

Path parameters
Name Description
projectId*
String
The Project ID.
Required
spaceId*
String
The Space ID. (Use '_default' without quotes to address the default Space.)
Required
documentName*
String
The Document name.
Required
attachmentId*
String
The Attachment ID.
Required
Query parameters
Name Description
revision
String
The revision ID.

Responses

Status: 200 - OK

Status: 400 - Bad Request

Status: 401 - Unauthorized

Status: 403 - Forbidden

Status: 404 - Not Found

Status: 406 - Not Acceptable

Status: 4XX-5XX - Error responses have the following structure: