How to access the Salesforce Marketing Cloud through simple-salesforce?

Atonal Wilson's picture

I am implementing a project using simple-salesforce so I can manage and trigger events on Salesforce Marketing Cloud. The problem I have encountered is that the documentation is not explicit if I can use simple-salesforce to access the Marketing Cloud endpoints.

I've noticed even that the login method on simple-salesforce can't be done by the Salesforce Marketing Cloud credentials. When I try to do this I get:

SalesforceAuthenticationFailed: INVALID_LOGIN: Invalid username, password, security token; or user locked out.

Did someone have the same issue? Can I access the Salesforce Marketing Cloud Certification through simple-salesforce?

2 Answers

Vivek Garg's picture

Hi,

 

You must utilize the Salesforce Marketing Cloud API in order to access the Salesforce Marketing Cloud with simple Salesforce.

 

 

 

Here are the steps to use simple-salesforce to access the Salesforce Marketing Cloud:

 

 

 

1. Verify that you have an API key and a Salesforce Marketing Cloud account. You'll need to get your access token, client secret, and client secret.

 

 

 

2. Run the following line in your command prompt or terminal to install the simple-salesforce package in your Python environment:

 

"pip install simple-salesforce"

 

3. Import the simple-salesforce library into your Python script:

 

Javascript: "from simple_salesforce import Salesforce"

 

 

 

4. Initialize the Salesforce object with your API credentials:

 

arduino: "sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token', client_id='your_client_id', client_secret='your_client_secret')"

 

 

 

5. Use the Marketing Cloud API methods provided by simple-salesforce to access your Marketing Cloud data. For example, to retrieve a list of your Marketing Cloud data extensions, you can use the following code:

 

csharp: "data_extensions = sf.restful('https://www.exacttargetapis.com/data/v1/customobjectdata/key/your_data_e...', params={'$page': 1, '$pageSize': 100})"

 

 

 

Keep in mind that the precise API endpoint and parameters you must use depend on the particular Marketing Cloud data you wish to access. For further details, consult the Marketing Cloud API documentation.

 

 

 

I'm done now! You should be able to use simple-salesforce in Python to access your Salesforce Marketing Cloud data after following these steps.

 

Right now, I doing Salesforce Admin certification training .

 

Thank you.

Vivek Garg

James Walker's picture

Hi There,

 

Follow these steps to gain access to the Salesforce Marketing Cloud using simple-salesforce:

 

1. Using pip, install the simple-salesforce library.

2. Import the simple_salesforce module in your Python script.

3. Create a SalesforceMarketingCloud instance by passing your Salesforce Marketing Cloud credentials.

4. Use the 'sfmc' object to interact with the Salesforce Marketing Cloud API. For example, you can retrieve data extensions.

5. Using the 'sfmc' object's relevant methods, do further activities such as adding, modifying, or removing data extensions.

 

That's all! You may now use simple-salesforce to access the Salesforce Marketing Cloud and execute different activities using the ways it provides.

 

Kind Regards 

James Walker

StickyMinds is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.