How to use simple salesforce (python library for salesforce) to add ShippingAddress field?

258    Asked by CamelliaKleiber in Salesforce , Asked on May 9, 2023

I have tried to upsert an account with Shipping Address using simple salesforce However, I am getting the error:

[{u'errorCode': u'JSON_PARSER_ERROR', u'message': u'Cannot deserialize instance of ShippingAddress from VALUE_STRING value abc or request may be missing a required field at [line:1, column:31]'}]
Below is my query.
    sf.Account.upsert(
        'Custom_Id__c/abc123',
        {
            'Name': 'abc',
            'RecordTypeId': '0121U000000G51AbC',
            'ShippingAddress': {        
                'City': 'abc',
                'Country': 'USA',
                'Street': 'Town Hall',
                'CountryCode': None,
                'PostalCode': None,
                'State': None,
                'StateCode': None,      
                'Accuracy': None,
                'Latitude': None,
                'Longitude': None,                  
            }               
        },

Any idea on how I can upsert shipping addresses properly using simple salesforce?

Answered by Diya tomar

Based on how the Address Compound Field works and just by looking at simple-salesforce docs, it seems you just need to use the individual compound field names here in your request without having the ShippingAddress attribute.


Your request should look as:
sf.Account.upsert(
    'Custom_Id__c/abc123',
    {
        'Name': 'abc',
        'RecordTypeId': '0121U000000G51AbC',
        'ShippingCity': 'abc',
        'ShippingStreet': 'Town Hall',
         ...
    }
)

Your Answer

Interviews

Parent Categories