2

I have tried to upsert an account with ShippingAddress 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 address properly using simple salesforce?

  • You will need to prefix the fields with the address in context. In this case e.g., ShippingCity, ShippingStreet, etc. – Jayant Das May 7 '19 at 20:35
  • @JayantDas This time I am getting a different error and it's Cannot deserialize instance of ShippingAddress from VALUE_NULL value null or request may be missing a required field at [line:1, column:43]'} – Mark May 7 '19 at 20:44
  • 2
    I don't know the working details of simple salesforce but I don't think you need ShippingAddress attribute at all. Just the individual field names and values. – Jayant Das May 7 '19 at 20:45
  • @JayantDas Thanks! that seems to have worked! – Mark May 7 '19 at 20:49
3

Disclaimer: I don't have any experience working with simple-salesforce and neither I am associated with it anyway.

But based on how the Address Compound Field works and just by looking at simple-salesforce docs, 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',
         ...
    }
)
| improve this answer | |

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.