| title | printDocument: createUploadSession |
|---|---|
| description | Create an upload session to iteratively upload ranges of binary file of printDocument. |
| ms.localizationpriority | medium |
| author | nilakhan |
| ms.subservice | universal-print |
| doc_type | apiPageType |
| ms.date | 04/04/2024 |
Namespace: microsoft.graph
Create an upload session that allows an app to iteratively upload ranges of a binary file linked to the print document.
As part of the response, this action returns an upload URL that can be used in subsequent sequential PUT queries. Request headers for each PUT operation can be used to specify the exact range of bytes to be uploaded. This allows transfer to be resumed, in case the network connection is dropped during upload.
Note: Creating an upload session using application permissions will only succeed if there is a printTask in a
processingstate on the associated print job, started by a trigger that the requesting app created. For details about how to register a task trigger, see Extending Universal Print to support pull printing.
[!INCLUDE national-cloud-support]
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
[!INCLUDE permissions-table]
To create an upload session using printer:
POST /print/printers/{id}/jobs/{id}/documents/{id}/createUploadSessionTo create an upload session using printerShare (supported with delegated permissions only):
POST /print/shares/{id}/jobs/{id}/documents/{id}/createUploadSession| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
| Content-Type | application/json. Required. |
In the request body, provide a JSON object with the following parameters.
| Parameter | Type | Description |
|---|---|---|
| properties | printDocumentUploadProperties | Represents properties of the binary file to be uploaded. |
The value of the contentType property in the request body should be supported by the printer/printerShare. You can get the supported content types by getting printerCapabilities of the printer/printerShare.
For OXPS to PDF conversion, you need to pass application/oxps as contentType for printer/printerShare that supports application/pdf.
Universal Print converts OXPS to PDF, when all the following conditions are met:
- The printer/printer share supports
application/pdfin printerCapabilities. - The printer/printer share does NOT support
application/oxpsin printerCapabilities. - The value for the contentType property in the request body is
application/oxps.
If successful, this method returns a 200 OK response code and a new uploadSession object in the response body.
Note: The uploadUrl property returned as part of the uploadSession response object is an opaque URL for subsequent
PUTqueries to upload byte ranges of the file. It contains the appropriate auth token for subsequentPUTqueries that expire by expirationDateTime. Do not change this URL.
The following example shows how to create an upload session that you can use in subsequent file upload operations to the specified printDocument.
POST https://graph.microsoft.com/v1.0/print/printers/{printerId}/jobs/{printJobId}/documents/{printDocumentId}/createUploadSession
Content-Type: application/json
{
"properties": {
"documentName": "TestFile.pdf",
"contentType": "application/pdf",
"size": 4533322
}
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
"uploadUrl": "https://print.print.microsoft.com/uploadSessions/5400be13-5a4e-4c20-be70-90c85bfe5d6e?tempauthtoken={token}",
"expirationDateTime": "2020-10-25T02:19:38.1694207Z",
"nextExpectedRanges": [
"0-4533321"
]
}