Extensions get, post, put?

Which http methods can I use in GenieACS extensions?
If I use the POST method, I get a timeout in GenieACS log, despite the fact that extension executes and ends in milliseconds when I test it manually in linux cli.
Does someone have a working example of an extension with the POST method?
Thanks in advance!

You are probably getting the timeout in the log because you are not calling the callback in the extension. Take this stripped down extension. I’ve put a few comments in here where the callback is invoked. This callback is what gets the data back to the provision or vparam script.

const process = require('process');
const API_URL = process.env.DASHBOARD_API_URL || 'https://my.domain.com/api/ACS/';

const url = require('url');
const http = require(API_URL.split(':', 1)[0]);

function getConfig(args, callback) {
    let params = JSON.parse(args[0]);

    const uri = API_URL + 'Foo?serial=' + params.serial + '&productClass=' + params.productClass + '&oui=' + params.oui + '&deviceId=' + encodeURIComponent(params.deviceId);

    let options = url.parse(uri);
    options.headers = {accept: 'application/json', 'content-type': 'application/json'};

    let request = http.post(options, function (response) {
        if (response.statusCode >= 400) {
            return callback(new Error('Unexpected error posting data. Response Code: ' + response.statusCode + '. Status Message: ' + response.statusMessage));

        let data = '';
        response.on('data', function (d) {
            data = data + d.toString();

        response.on('end', function () {
            let result = JSON.parse(data);

            // Invoke the callback so our results get back to the calling provision script
            return callback(null, result);

    request.on('error', function (err) {
        // Let the calling script know there was an error

exports.getConfig = getConfig;


Thank you for your answer. But I didn’t ask about the GET method, which works fine for me. I asked about the POST method. My script used in extension called from GenieACS returns timeout if I use POST or PUT.
The same script called manually with a node in a Linux bash environment returns callback and ends in a few milliseconds. I didn’t analyse GenieACS code so I prefer ask if it is possible to use in extensions other http methods than GET. My current case is PUT cause I want explitly “inform” my CRM that provisioning just finished. May be that I didn’t clarify it before, sorry :wink:

Sorry, this was the shorter of the methods in an extension script I have, one of which posts. But request.post should work fine in the above example, as long as you call the callback when you are done.

Here is a post example:

function diagnostic(args, callback) {
    let params = JSON.parse(args[0]);

    const uri = API_URL + "Diagnostic?serial=" + params.serial + '&productClass=' + params.productClass + '&oui=' + params.oui;
    const logParams = { deviceId: params.deviceId };
    logger.info(Object.assign({ message: uri }, logParams, params));

        uri: uri,
        method: 'POST',
        json: true,
        body: params
    }, function (error, response) {
        if (!error && response.statusCode === 200) {
            callback(null, {});
        } else {
            logger.error(Object.assign({ message: 'Unexpected error sending event', statusCode: response.statusCode, statusMessage: response.statusMessage }, logParams));