How to update modules to New Connection

Trying to update connections in Open AI Modules in scenarios. Have the below code. What should the connection ID be - Where can I find them.

import requests

Constants

API_BASE_URL = “https://eu1.make.com/api/v2
API_TOKEN = “abcdefab-1234-5678-abcd-112233445566”
NEW_CONNECTION_ID = “new_connection_id” # Replace with your new connection ID
OLD_CONNECTION_ID = “old_connection_id” # Replace with your old connection ID

Function to get all scenarios

def get_scenarios():
url = f"{API_BASE_URL}/scenarios"
headers = {
“Authorization”: f"Token {API_TOKEN}"
}
response = requests.get(url, headers=headers)
response.raise_for_status() # Check for HTTP errors
return response.json()

Function to update a module in a scenario

def update_module(scenario_id, module_id, update_data):
url = f"{API_BASE_URL}/scenarios/{scenario_id}/modules/{module_id}"
headers = {
“Authorization”: f"Token {API_TOKEN}",
“Content-Type”: “application/json”
}
response = requests.patch(url, headers=headers, json=update_data)
response.raise_for_status() # Check for HTTP errors
return response.json()

Hi @Real_Internet_Sales,

It seems you are using the Make API. The connectionID is the ID of the connection, you cannot updated it to a new ID as this is the ID that points to the resource itself. You can retrieve the ID via the List connections endpoint.

If you want to update an existing connection, you can do this via the Set connection data endpoint:https://www.make.com/en/api-documentation/connections-connectionId-set-data-post

Cheers,
Henk

1 Like