Ask Your Question
0

Exporting topology with REST API or SDK

asked 2020-05-21 03:57:27 -0500

almonds567 gravatar image

Hi, I am trying to export topology using REST API call but I am getting an error:

{
    "ISSUES": [
        {
            "code": "TOPOLOGY_13",
            "message": "Cannot export topology 'topologyID' due to 'null'"
        }
    ]
}

My code in python:

url = control_hub_url + "/topology/rest/v1/topologies/exportTopologies"

body = "[\"toplogyID\"]"
headers = {
    'content-type': "application/json",
    'x-ss-rest-call': "true",
    'x-ss-user-auth-token': "token from login call",
    'x-requested-by': "SCH",
    'accept-encoding': "application/gzip",
    'accept': "*/*",
    }

response = requests.request("POST", url, data=body, headers=headers)

I tried changing values for accept and accept-encoding but I was still getting the same error. If I try to export from the Streamsets app, it works and I get the zip file. Did anyone manage to export topology using API or SDK?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-05-21 12:23:49 -0500

Manjit gravatar image

updated 2020-05-22 16:00:46 -0500

Unfortunately this is not supported with SDK for Python yet. But, it should work with rest api. I just verified with valid topology commit id and got the zip content back. Since, you are already using python to make the rest api call, I would suggest converting the body to json string using json module instead

response = requests.post(contro_hub_url + '/topology/rest/v1/topologies/exportTopologies',
                                      data=json.dumps(['9f010cf6-099e-40f9-a4e3-9a2fbe9142ad:admin']),
                                      headers=headers)
edit flag offensive delete link more

Comments

Hi Manjit. Thanks for the answer. I tried changing the body but I get the same error. Could you please send me API call you used (any language is fine) to see what I am doing wrong? I tried in Postman also, same error.

almonds567 gravatar imagealmonds567 ( 2020-05-22 04:12:08 -0500 )edit
1

Seems like the body should contain topology commit IDs instead of topology ids. My bad, I mentioned that I was using topology ID in my answer but, I was actually using topology commit ID. Edited the answer.

Manjit gravatar imageManjit ( 2020-05-22 15:59:46 -0500 )edit
1

answered 2020-05-26 09:10:26 -0500

almonds567 gravatar image

Thanks Manjit. It worked after adding commit ID in the request body. I am sharing my code.

url = "<your Control Hub url>/topology/rest/v1/topologies/exportTopologies"
body = "[\"topology-commit-id\"]"
headers = {
    'content-type': "application/json",
    'x-ss-rest-call': "true",
    'x-ss-user-auth-token': "session-id-from-login-request",
    'x-requested-by': "SCH"
    }

response = requests.request("POST", url, data=body, headers=headers)

if response.status_code == 200:
    if response.headers.get('Content-Disposition'):
        print("Writing file to topology.zip")
        open("topology.zip", 'wb').write(response.content)
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-05-21 03:57:27 -0500

Seen: 58 times

Last updated: May 26