Reputation: 1597
What is the right JSON format to post a geolocation (point) to the Salesforce REST API? I am getting either deserialization or permission errors (despite wide open administrator permissions in my sandbox).
I tried:
{"location__c": {"latitude": 34, "longitude": 23}} # the actual return when a GET the field
and
{"location__c__latitude": 34, "location__c__longitude": 23}
and
{"latitude__c": 34, "longitude__c": 23} # this one out of desperation.
Obviously with all the necessary boilerplate and authentication. Posting to other custom fields works just fine.
Upvotes: 1
Views: 525
Reputation: 1660
As per https://help.salesforce.com/apex/HTViewHelpDoc?id=custom_field_geolocate_overview.htm&language=en you need to specify them in a slightly different format, like so:
location__latitude__s, location__longitude__s
So, if you have an object with a geolocation (let's say an object called "house"), you'd do
{"house":{"location__latitude__s":34, "location__longitude__s":23}}
Upvotes: 2