Downlink Analysis Problem

Downlink Analysis Problem

Hello, i wrote this script for sending a downlink to an blueprint device:


  1. const { Account, Resources, Analysis, Device, Utils, Services } = require("@tago-io/sdk");
    async function updateTag(context, scope) {
      // Requires scope to know what device and what widget called it
      if (!scope[0]) throw "Scope is missing";

      // Read the stored account_token and make an account object
      const env_vars = Utils.envToJson(context.environment);
      const account = new Account({ token: env_vars.account_token });
      const res = new Resources({ token: env_vars.account_token });

      // Get the device id of the caller
      const origin = scope[0].device;

      const dd = scope.find(x => x.variable === 'downlink_data');
      port = { value: 2 };

      console.debug(`Device ID: ${scope[0].device}`);

      const result = await Utils.sendDownlink(account, origin, {
        payload: "ZwIBAmwW",
        port: Number(port.value),
        confirmed: false,
      }).catch((error) => error);

      console.log(result);

    }
    module.exports = new Analysis(updateTag);
This is the error i am receiving:

[2024-01-30 13:50:49] Analysis Called.
[2024-01-30 13:50:49] Duration: 1.7s Billed Duration: 2s.
[2024-01-30 13:50:49] Analysis finished.
[2024-01-30 13:50:49] Downlink failed with status 400: {"message":"Missing Authorization Optional Parameters: region and connID"}
[2024-01-30 13:50:48] > TagoIO-SDK: No region or env defined, using fallback as usa-1.
[2024-01-30 13:50:48] Device ID: 65b9172ad1ae0b00091a9bea

It almost worked because it created the downlink in the configurations parameters, port however is missing:



Am i missing something :( ? Could you help?