insertDatabaseConnection method
Implementation
Future<http.Response> insertDatabaseConnection({
required String dbName,
required String host,
required String password,
required String port,
required String username,
required String databaseName,
required String databaseType,
bool isNoSql = false,
bool isEncrypt = false,
}) async {
final url = Uri.parse('$baseUrl/insertDatabaseConnectionInfo?workspaceId=$workspaceId');
final headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer $token',
};
final body = jsonEncode({
"database_attributes": {
"dbName": dbName,
"host": host,
"password": password,
"port": port,
"username": username
},
"database_name": databaseName,
"database_type": databaseType,
"is_nosql": isNoSql,
"is_encrypt": isEncrypt
});
print("Request Body = $body");
try {
final response = await http.post(url, headers: headers, body: body);
print("Response Status Code: ${response.statusCode}");
print("Response Body: ${response.body}");
return response;
} catch (e) {
print("Error occurred: $e");
throw Exception('Failed to insert database connection');
}
}