Copy Variable Values

This endpoint copies one or more Variable values to other specified existing Variables.

Request

To copy one or more Variable values, make a POST request to the following URL:

HTTP MethodURL
POSThttps://industrial.api.ubidots.com/api/v2.0/variables/_/migrate_values/

Query Parameters

ParameterTypeUseDescription
tokenStringAuthenticationThe authentication token can optionally be sent as a query parameter.

Body Parameters

ParameterTypeRequired?Default ValueDescription
variablesArrayYesN/A (required)Array of objects containing to and from arrays. See the example below.
startDateNumberNoStart date from which Values are copied. If not provided, Values are copied from the first Value.
endDateNumberNoEnd date to which Values are copied. If not provided, Values are copied until the last Value.
🚧

Attention

Please note that both Variables have to exist and that the authentication token has to have permissions to view and edit Variables.

📘

variables Array of Body

Please see a valid example of the variables array in the body below:

Header

ParameterTypeDescription
X-Auth-TokenStringAuthentication Token of account
Content-TypeString (application/json)Content type of the request body
//variables body attribute

//Please note that "device" key is optional if Variable is an Id, otherwise it's required

"variables": [
    { 
      "from": { "variable": originVariable1ID },  
      "to": { "device": "~targetDevice1", "variable": "~targetVariable1" }
    },
  	{ 
      "from": { "variable": originVariable2ID },  
      "to": { "device": "~targetDevice2", "variable": "~targetVariable2" }
    },
  	{ 
      "from": { "variable": originVariableNID },  
      "to": { "device": "~targetDeviceN", "variable": "~targetVariableN" }
    }
  
  ]
curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/variables/_/migrate_values/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '{
  "variables": [
    { 
        "from": { "variable": "5f073bfb4763e7780a77bba2" },
        "to": { "device": "~device1", "variable": "~variable1" }
    }
  ],
  "startDate": None,
  "endDate": None
}}'
{
    "task": {
        "id": "5ebda96e73efc323d89a628c"
    }
}
{
    "code": 400001,
    "message": "Validation Error.",
    "detail": {
        ....
    }
}
{
    "code": 401001,
    "message": "Authentication credentials were not provided.",
    "detail": "Authentication credentials were not provided."
}

Response

Returns a task ID for the asynchronous process.