I am trying to upload new records by calling a REST API but am getting the following error.

simple_salesforce.exceptions.SalesforceGeneralError: Error Code 405. Response content: [{'errorCode': 'METHOD_NOT_ALLOWED', 'message': "HTTP Method 'PATCH' not allowed. Allowed are GET,HEAD,POST"}]

Here is my code:

session_id, instance = SalesforceLogin(username='[email protected]',

sf = Salesforce(session_id=session_id,

account = SFType('Account', session_id, instance)

upload_data = {"Name": "Test Company"}

record_id = 'Id'
account.upsert(record_id=record_id, data=upload_data)

1 Answer 1


Salesforce Error Codes can be found here REST API Developer Guide

405 errors usually occur when the endpoint is not formatted correctly:

The method specified in the Request-Line isn’t allowed for the resource specified in the URI.

In your case, it looks like you are trying to send a PATCH request to /services/data/v51.0/sobjects/Account/Id, where 'Id' should be the actual 001... 15 (case-sensitive) /18 (case-insensitive) character long Account Id.

This is easily replicated: enter image description here

  • I'm new to Salesforce APIs. What's the best practice around upserting new records via REST API? I am a bit confused on what to use for the external id. My goal is to be able to bulk upload new / update existing records. @gale-force-wizard
    – codr
    Apr 22, 2021 at 13:48
  • @ParthPatel Salesforce provides great learning resources on Trailhead. I'd suggest you start there: trailhead.salesforce.com/en/content/learn/modules/api_basics/… Apr 22, 2021 at 19:11
  • Great will look into it. Thank you!
    – codr
    Apr 23, 2021 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .