+ Reply to Thread
Results 1 to 4 of 4

Thread: Example API code not working

  1. #1
    Join Date
    Jul 2016
    Posts
    10

    Default Example API code not working

    Hi,

    Trying to understand the API structure and have built a web page with JavaScript to create a new job. Should this work (tags and usernames etc. amended)?

    Thanks for any advice.

    <** !DOCTYPE html **>
    <** html **>
    <** title **>Fiery API<** /title **>
    <** body **>

    <** h1 **>This is a Fiery API test to submit a job<** /h1 **>

    <** script **>
    var loginJson = {
    username: **username**,
    password: **password**,
    accessrights: **apikey**,
    };

    var payload = JSON.stringify(loginJson);

    var options = {
    hostname: **hostname**,
    path: '/live/api/v3/login',
    method: 'POST',
    headers: {
    'Content-Type': 'application/json',
    'Content-Length': payload.length,
    },

    rejectUnauthorized: false,
    };

    var req = https.request(options, function (res) {
    var response = '';

    res.setEncoding('utf8');
    res.on('data', function (chunk) {
    response = response + chunk;
    }).on('end', function () {
    // do something with the response here

    // cookie is needed for other api requests
    var cookie = res.headers['set-cookie'];
    });
    });

    req.write(payload);
    req.end();

    fullPath = 'C:\SmartFolders\BlankPDFs\Blank-UK.pdf' # e.g. d:\business_card.pdf
    fs.stat(fullPath, function(err, stats) {
    restler.post('https://' + hostname + '/live/api/v3/jobs', {
    multipart: true,
    headers: {
    cookie: cookie,
    },

    rejectUnauthorized: false,

    data: {
    file: restler.file(fullPath, null, stats.size, null, 'application/octet-stream'),

    // override default number of copies to 1 copies
    'attributes[num copies]': 1,
    },
    }).on('complete', function(response) {
    // do something with the response here

    });
    });
    <** /script **>
    <** /body **>
    <** /html **>

    Last edited by kfstarkey; 07-11-2016 at 11:37 PM.

  2. #2
    Yusuke_K is offline Senior Fiery Forum Contributor Yusuke_K is on a distinguished path
    Join Date
    Jul 2009
    Posts
    57

    Default

    Hi there,

    Thank you for your interest in Fiery API!

    Have you installed the latest Fiery API to your Fiery?
    The code is for v3 (live/api/v3) so you need to download the latest installer from developer.efi.com and install directly to your Fiery server. You need to create our EFI Passport account to get to the download page. You also need evaluation key to get this working.

    If you've done that already and still having problem then we'd like to know a bit more detail of what part is not working. Have you able to at least login to Fiery successfully through Fiery API?

    Please let me know!
    Yusuke

  3. #3
    Join Date
    Jul 2016
    Posts
    10

    Default

    Hi and thanks for the reply.

    To answer, yes we have installed the latest version, v3 using the installer Agali-3.0.00.26.exe

    When we run a https://fierycentral/live/api/v3/version/ we see the following: -

    {"AgaliVersion":"3.0.00.26","RubyVersion":"1.9.03.150c","RhythmVersion":"v3.0.03","installed":"2016-03-09T06:45:12+00:00"}

    We also have a a key which we are setting in accessrights.

    I 'think' the problem is authentication, I've found a couple of debuggers, one reports: -

    {
    "authenticated": false,
    "error_code": "",
    "errors": "no accessrights found",
    "fiery": false
    }

    the when the following code is executed: -

    var loginJson = {
    username: 'FIERY_CENTRAL',
    password: '********',
    accessrights: 'PP8yrJ4dxysQ9gYuX... ...',
    };

    var payload = JSON.stringify(loginJson);

    var options = {
    hostname: 'FIERYCENTRAL',
    path: '/live/api/v3/login',
    method: 'POST',
    headers: {
    'Content-Type': 'application/json',
    'Content-Length': payload.length,
    },

    rejectUnauthorized: false,
    };

    var req = https.request(options, function (res) {
    var response = '';

    res.setEncoding('utf8');
    res.on('data', function (chunk) {
    response = response + chunk;
    }).on('end', function () {
    // do something with the response here

    // cookie is needed for other api requests
    var cookie = res.headers['set-cookie'];
    });
    });

    req.write(payload);
    req.end();

    fullPath = 'C:\SmartFolders\BlankPDFs\Blank-UK.pdf' # e.g. d:\business_card.pdf
    fs.stat(fullPath, function(err, stats) {
    restler.post('https://' + hostname + '/live/api/v3/jobs', {
    multipart: true,
    headers: {
    cookie: cookie,
    },

    rejectUnauthorized: false,

    data: {
    file: restler.file(fullPath, null, stats.size, null, 'application/octet-stream'),

    // override default number of copies to 10 copies
    'attributes[num copies]': 10,
    },
    }).on('complete', function(response) {
    // do something with the response here
    });
    });

    Appreciate your help.
    Regards,
    Kevin

  4. #4
    Yusuke_K is offline Senior Fiery Forum Contributor Yusuke_K is on a distinguished path
    Join Date
    Jul 2009
    Posts
    57

    Default

    Hi there,

    We do not see any issue with your code.

    Could you clarify if you are trying to connect with Fiery Central server as your user name indicates?

    Also if possible please share your evaluation key you received from developer.efi.com.
    We'd like to double check your evaluation key works properly. Please contact me at yusuke.kondo@efi.com directly.

    Thank you,
    Yusuke

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts