Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPP Missing attribute on CUPS-Get-Devices using node.js ipp module

I am having a problem with Missing required attribute for CUPS-Get-Devices. Basically I want to get list of available printers with IPP and CUPS using https://www.npmjs.org/package/ipp.

I've implemented CUPS-Get-Devices into the package as it had not support the attribute for the package but I get it working. Problem is that the response respond with "status-message": "Missing required attributes." and not giving me the list of printers.

var uri = "http://localhost:631"
var data = ipp.serialize({
  "operation": "CUPS-Get-Printers",
  "operation-attributes-tag": {
  "attributes-charset": 'utf-8',
  "attributes-natural-language": 'en-us',
  "limit": 10
 }
});

ipp.request(uri, data, function(err, res){
  if(err){
    return console.log(err);
  }
  console.log(JSON.stringify(res,null,2));
});

The response is

{
  "version": "2.0",
  "statusCode": "client-error-bad-request",
  "id": 67392993,
  "operation-attributes-tag": {
    "attributes-charset": "utf-8",
    "attributes-natural-language": "en-us",
    "status-message": "Missing required attributes."
  }
}

The documentation doesn't say anything about other required parameters http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_PRINTERS

Does anybody know where's the problem? Thank you!

like image 331
Jakub Avatar asked Nov 01 '22 21:11

Jakub


1 Answers

This code works for me, with an unmodified ipp library and with CUPS 1.7.3. My best guess is that you've made a typo or something when you modified the library.

var ipp = require('ipp');

// Add missing operation code
ipp.operations['CUPS-Get-Printers'] = 0x4002;

// The rest is identical to your code:

var uri = "http://localhost:631";
var data = ipp.serialize({
  "operation": "CUPS-Get-Printers",
  "operation-attributes-tag": {
    "attributes-charset": 'utf-8',
    "attributes-natural-language": 'en-us',
    "limit": 10
  }
});

ipp.request(uri, data, function(err, res){
  if(err){
    return console.log(err);
  }
  console.log(JSON.stringify(res,null,2));
});
like image 169
pdw Avatar answered Nov 12 '22 16:11

pdw