Universal Print: The requesting-user-uri attribute is required when the provided my-jobs attribute is true
TL;DR Ensure that you send your PDFs to Universal Print as a byte array of the PDF and not a byte array of a base64 encoded PDF or you’ll get an error message telling you your missing the requesting-user-uri not that your document is wrongly encoded.
This one is very, very odd. It’s taken longer than it should have to resolve because the error message suggests its an authentication issue when in fact its a data issue.
As part of our Simple Tracker product we wanted to use Universal Print to act as a print queue for those people who produce lists of tasks or ‘special’ tasks that result in instruction sheets. So we used the following process:
- Generate a word document.
- Store it in SharePoint.
- Generate a PDF document from the Word document, as Universal Print does not support printing Office Documents directly.
- Authenticate the user against Universal Print using a PublicClientApplication, as MSGraph does not support placing print jobs by applications.
- Get the Printer Share
- Create a Print Job on the printer share
- Upload the PDF document to the print job
- Start the print job
- Poll the print job until it completes or aborts
Eventually we would get a message on the print job poll:
The print job was cancelled by the system or user
Checking Universal Print in the Azure Portal we would get:
Aborted
Checking the Event Viewer / Application and Services Logs /Microsoft / Windows / Print Connector / Operational on the print server we would get:
Request Details:
Operation ID: GetPrinterAttributes
Request ID: 1
Version: 2.0
Attributes:
Attribute Group: OperationAttributes
Attribute attributes-charset: SimpleIppValue-Type:Charset-Value:UTF-8
Attribute attributes-natural-language: SimpleIppValue-Type:NaturalLanguage-Value:en-us
Attribute printer-uri: SimpleIppValue-Type:Uri-Value:ipps://print.print.microsoft.com/printers/GUID
Attribute output-device-uuid: SimpleIppValue-Type:Charset-Value:urn:uuid:GUID
Attributes:
Attribute detailed-status-message: SimpleIppValue-Type:TextWithoutLanguage-Value:The requesting-user-uri attribute is required when the provided my-jobs attribute is true — The requesting-user-uri attribute is required when the provided my-jobs attribute is true
Event Xml:
<Event xmlns=http://schemas.microsoft.com/win/2004/08/events/event><System>
<Provider Name=”Microsoft-Windows-PrintConnector” Guid=”{GUID}” />
<EventID>12</EventID>
<Version>0</Version>
<Level>3</Level>
<Task>65522</Task>
<Opcode>0</Opcode>
<Keywords>0x8000f00000000000</Keywords>
<TimeCreated SystemTime=”2021–09–30T15:34:35.526946900Z” /><EventRecordID>3342</EventRecordID>
<Correlation />
<Execution ProcessID=”5404" ThreadID=”932" />
<Channel>Microsoft-Windows-PrintConnector/Operational</Channel>
<Computer>printserver</Computer>
<Security UserID=”SID" />
</System>
<EventData>
<Data Name=”reason”>IPP service returned failure:
IPP Request operation: GetPrinterAttributes
Uri: https://print.print.microsoft.com/printers/GUID
response:StatusCode: 200, ReasonPhrase: ‘OK’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
MS-CV: B6pbpomiuUOm8vne.0
X-Cache: CONFIG_NOCACHE
X-MSEdge-Ref: Ref A: FE6E8211FFDE480E95F3EBFE5A794AD1 Ref B: VIEEDGE2111 Ref C: 2021–09–30T15:34:34Z
Cache-Control: no-store, must-revalidate, no-cache, max-age=0
Date: Thu, 30 Sep 2021 15:34:35 GMT
Set-Cookie: UserRegion=europe; path=/; samesite=lax; httponly
Content-Type: application/ipp
}
Printer info:
(Name: Lex_Printer_Universal_Print, CloudDeviceId: GUID, PhysicalDeviceId: GUID.-ID)
IPP Response Details:
Status code ClientErrorBadRequestResponse ID 1Version: 2.0
Attributes:
Attribute Group: OperationAttributes
Attribute attributes-charset: SimpleIppValue-Type:Charset-Value:utf-8
Attribute attributes-natural-language: SimpleIppValue-Type:NaturalLanguage-Value:en-us
Attribute detailed-status-message: SimpleIppValue-Type:TextWithoutLanguage-Value:The requesting-user-uri attribute is required when the provided my-jobs attribute is true — The requesting-user-uri attribute is required when the provided my-jobs attribute is true
Request Details:
Operation ID: GetPrinterAttributes
Request ID: 1
Version: 2.0
Attributes:
Attribute Group: OperationAttributes
Attribute attributes-charset: SimpleIppValue-Type:Charset-Value:UTF-8
Attribute attributes-natural-language: SimpleIppValue-Type:NaturalLanguage-Value:en-us
Attribute printer-uri: SimpleIppValue-Type:Uri-Value:ipps://print.print.microsoft.com/printers/GUID
Attribute output-device-uuid: SimpleIppValue-Type:Charset-Value:urn:uuid:GUID
Attributes:
Attribute detailed-status-message: SimpleIppValue-Type:TextWithoutLanguage-Value:The requesting-user-uri attribute is required when the provided my-jobs attribute is true — The requesting-user-uri attribute is required when the provided my-jobs attribute is true
</Data>
</EventData>
</Event>
Okay so based on the only detailed error message it looks like an authentication issue with the request being sent not having the correct details.
Its not.
It happens when you pass an incorrectly encoded byte array.
The problem was in this step
- Generate a PDF document from the Word document
We did do this but passed it back as a base64 encoded string. We then passed this encoded string as a byte array in an array buffer rather than decoding it first.
Problem being the only error message we had was:
Attribute detailed-status-message: SimpleIppValue-Type:TextWithoutLanguage-Value:The requesting-user-uri attribute is required when the provided my-jobs attribute is true — The requesting-user-uri attribute is required when the provided my-jobs attribute is true
So we decoded the base64 string and passed it as a byte array in an array buffer and the problem was solved.
TL;CR Ensure that you send your PDFs to Universal Print as a byte array of the PDF and not a byte array of a base64 encoded PDF or you’ll get an error message telling you your missing the requesting-user-uri not that your document is wrongly encoded.