An absolute python newbie & trying to establish a connection between python & salesforce. Followed this documentation - https://pypi.org/project/simple-salesforce/ and we have a python script that has a payload similar to the one mentioned in the above link.

Here is a sample of my payload with result --

payload = {
  "firstname": "test",
"lastname" : "name",

result = sf.apexecute('/applications', method='POST', data=payload)


where /applications is the end point url in the apex rest service.

I am able to establish the connection with UN, PW, Instance url & Token but I get the below error when I run my python run.py

 /simple_salesforce/util.py", line 61, in exception_handler
    raise exc_cls(result.url, result.status_code, name, response_content)
**simple_salesforce.exceptions.SalesforceResourceNotFound: Resource apexexcute Not Found. Response content: [{'errorCode': 'NOT_FOUND', 'message': 'The requested resource does not exist'}]**

What could be the issue?


That's not an authentication error. You are calling the wrong method on your simple_salesforce connection object. I believe you're receiving that specific error message due to how simple_salesforce translates Python method calls into REST endpoints.

The apexecute method is for calling custom Apex REST endpoints. From the simple_salesforce documentation:

result = sf.apexecute('User/Activity', method='POST', data=payload)

This would call the endpoint https://.salesforce.com/services/apexrest/User/Activity with data= as the body content encoded with json.dumps

Your error message suggests you've spelled this wrong, as apexexcute. Make sure to call the method as documented, and include the portion of your REST service's URL after /apexrest/ only in the first parameter.

Note that with simple_salesforce, you create sObject records like this:


replacing Contact with the API name of the sObject you want to create. If that is your use case, it's not necessary to go all the way to an Apex REST service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.