I am inserting object into salesforce using REST API. I have one field with Geolocation data-type.
How can inset value to this field using java? My example code is below.
parishud.put(“gps__c”,?????);
there are two fields to insert(gps(Latitude) gps(Longitude)) but in API i found only one field with name gps__c
HttpClient client = new httpclient.HttpClient();
JSONObject parishud = new JSONObject();
try {
parishud.put("Name","ParishudhTest4");
parishud.put("entitled__c","Yes");
parishud.put("Comments__c","Comments");
parishud.put("fallill_count_after__c","5");
parishud.put("fallill_count_before__c","7");
parishud.put("influencedcount__c","8");
parishud.put("toiletusaseperday__c","3");
parishud.put("parishudhid__c","002");
parishud.put("Received_NBA_Incentive__c","Yes");
parishud.put("Received_NREGA_Incentive__c","Yes");
//parishud.put("gps__c",?????);
PostMethod postaccount = new PostMethod("https://ap1.salesforce.com/services/data/v20.0/sobjects/Parishudh__c/");
postaccount.setRequestHeader("Authorization", "OAuth " + accessToken);
postaccount.setRequestEntity(new StringRequestEntity(parishud.toString(),"application/json", null));
client.executeMethod(postaccount);
The Geolocation field is actually composed out of 3 fields, 2 of which are accessible for us.
If your field name is
gpsthen you can store your data ingps__Latitude__sandgps__Longitude__s(note the double underscore in the beginning like it’s a managed package and the ending is “s”, not “c”).Make sure you have set profile-level security for your Java integration user to be able to access this field.
If you need code samples – you can check my answer How do I integrate Salesforce with Google Maps? or for example http://blog.internetcreations.com/2012/09/creating-a-geolocation-trigger-in-salesforce-winter-13/