Web Services After Operation Rule to Connect to JDBC to execute phyton script

Hi All,

We are using a Web Service connector for Tableau and one of the requirements is to execute a phyton script after adding a user into a group. Script is needed since there is no API available to perform the needed function from Tableau. The only available API for our requirements is for adding the users into the group. I would just like to ask if there is an available template for Web Services After Operation Rule to connect to a JDBC and once connected, execute the stored procedure/phyton script inside the database?

Thank you!!

Hi @jasmedina,

Use below API to achieve your case:
Method : POST
Context-URL : /api/api-version/sites/site-id/groups/group-id/users
Body :
add single user

<tsRequest>
  <user id="user-id" />
</tsRequest>

if you want to add multiple users

<tsRequest>
  <users>
	<user id="user-id1" />
	<user id="user-id2" />
	<user id="user-id2" />
  </users>
</tsRequest>

You may check below tableau documentation more information:
Users and Groups Methods - Tableau

Thank You.

Hi @gogubapu! I was able to add the users into the groups. However, I need to execute a script after adding the users which is why I need to use an after rule.

Hi @jasmedina ,

You need to use after rule achieve your case, Find below sample code for after operation rule.

import connector.common.JsonUtil;
import sailpoint.connector.webservices.WebServicesClient;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.CallableStatement;

    try {
        // Database URL
        String jdbcURL = "jdbc:mysql://localhost:3306/yourDatabase";
        // Database credentials
        String username = "yourUsername";
        String password = "yourPassword";

        Connection connection = null;
		CallableStatement statement;
        try {
            // Establish the connection
            connection = DriverManager.getConnection(jdbcURL, username, password);
            log.error("Connection established successfully!");
			statement = connection.prepareCall("{call StoredProcedureName(?,?)}");
			statement.setString(1, "");
			statement.setString(2, "");
			statement.executeUpdate();
			
		}
		catch (SQLException e) {
            log.error(e);
		}
		
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }

Thank you.

2 Likes

Web Services connector will not be able to do this, but JDBC connector can execute additional queries inside the connected DB.

1 Like

Hi @MVKR7T! Does it mean that even via connector rule in the webservice, I wont be able to execute stored procedures?

Webservice Connector Rules are to make API calls or run some logics inside SailPoint connector space.

Whereas JDBC, you establish connection to the DB and execute whatever queries you need to.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.