Problem sending Scope

Hi,

I have an analysis sending scope for another analisys.

I tried Python SDK doc:

import tago

my_account = tago.Account('MY_ACCOUNT_TOKEN')

# Your scope can be an array with several objects
scope = [
    {
        'variable': 'alarm',
        'value': 'On'
    }
]

result = my_account.analysis.run('ANALYSIS_ID_HERE', scope)
print(result)

I´m getting this error on console:
{'status': False, 'result': {'request_error': 'Unexpected token v in JSON at position 0', 'request_body': 'variable=value', 'server_response': 'Malformed request syntax'}}

I tried to dump scope:

scope = json.dumps([

    {

      'variable': 'data_final_mensal_cafe',

      'value': str(filter_last_day)

}])

It´s ok on console when I print result:
{'status': True, 'result': 'Starting analysis'}

But I´m not getting anything when I try to log scope on another analysis (Node.js):
async function myAnalysis(context, scope) { context.log(JSON.stringify(scope));

Could you help me?

Let us check this issue and we will get back to the post soon.

Hi @augustoleandro,

The problem is happening because your json is wrong. The correct json based on yours is:

scope = json.dumps({
    "scope":{
        "variable": "data_final_mensal_cafe",
        "value": "test"
        }
})

The print on console in test is: [{‘variable’: ‘data_final_mensal_cafe’, ‘value’: ‘test’}]

Is missing “scope” before the data. Test and let me know if work correctly.

Regards, Rafael Teles.

1 Like

Thank you Rafael! It´s working now!

2 Likes