Support Questions
Find answers, ask questions, and share your expertise

Unable to Create connection between two ports in NIFI using NiPy API

Unable to Create connection between two ports in NIFI using NiPy API

Hi ,

I am trying to create a connection between two ports using NiPy ports. But its failing. Find below me code:

conSourceToTarget = """{ 
    "revision": {
        "clientId": "439a9b14-015c-1000-5924-200a7fdaf626",
        "version": 0
    },
    "component": {
        "name": "",
        "source": {
            "id":  """  +  "\"" +  sourcePortID +  "\"" + """ ,
            "groupId": """  +  "\"" +  sourceProcessGroup.id  +  "\"" + """ ,
            "type": "OUTPUT_PORT"
        },
        "destination": {
            "id": """  +  "\"" +  targetPortID +  "\"" + """ ,
            "groupId": """  +  "\"" +  targetProcessGroup.id +  "\"" + """ ,
            "type": "INPUT_PORT"
        },
        "selectedRelationships": ["success"],
        "flowFileExpiration": "0 sec",
        "backPressureDataSizeThreshold": "1 GB",
        "backPressureObjectThreshold": "10000",
        "bends": [],
        "prioritizers": []
    }
}"""
nipyapi.nifi.ProcessGroupsApi().create_connection(rootId,conSourceToTarget)




Error:

nipyapi.nifi.rest.ApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Content-Type': 'text/plain', 'Date': 'Tue, 20 Nov 2018 14:13:46 GMT', 'Content-Length': '1091', 'Server': 'Jetty(9.4.3.v20170317)', 'X-Frame-Options': 'SAMEORIGIN', 'Vary': 'Accept-Encoding'}) HTTP response body: Cannot construct instance of `org.apache.nifi.web.api.entity.ConnectionEntity` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('{ "revision": { "clientId": "439a9b14-015c-1000-5924-200a7fdaf626", "version": 0 }, "component": { "name": "", "source": { "id": "6f467496-5908-341c-a850-027246a6ecd8" , "groupId": "1e5c4c75-0681-37c4-ad3c-b89ab52886ff" , "type": "OUTPUT_PORT" }, "destination": { "id": "9b0a5ca9-7367-3236-be2d-e8ccc7ee6498" , "groupId": "a0602771-9860-31af-8bc2-95cc6096c391" , "type": "INPUT_PORT" }, "selectedRelationships": ["success"], "flowFileExpiration": "0 sec", "backPressureDataSizeThreshold": "1 GB", "backPressureObjectThreshold": "10000", "bends": [], "prioritizers": [] } }') at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]