How to pass a JSON body from an API call to scenario

Srini_E Registered Posts: 14


I'm trying to pass a JSON body from an API call to trigger a scenario. The scenario has a step (set global variables) to update global variables, I want to pass the JSON body to the variables field as shown in the screenshot.

Could anyone please help me on this?


Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,209 Dataiker
    edited July 17 Answer ✓

    Hi @Srini_E

    Variable expansion is not supported within the "variables" when setting a variable this must be json.

    What you can do is use evaluated variables instead by toggling it "on".

    1. Using Evaluated variables :  Screenshot 2022-10-26 at 15.00.02.png

    2. Using Python step ( example below will read project variable and want to set a global variable)

    import dataiku
    client = dataiku.api_client()
    project = dataiku.api_client().get_project(dataiku.default_project_key())
    vars = project.get_variables()
    #retrieve the variable
    var_to_set = vars['standard']['varname']
    global_variables = client.get_variables()
    global_variables["varname"] = var_to_set


Setup Info
      Help me…