function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brandon COFFINBrandon COFFIN 

REST API multiple upsert using external id

Hello,

I have to perform a multiple upsert of the standard object Product using an external ID.
I found this https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm and this http://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_api_rest.htm#sobject_tree_resource but it doesn't help me.
Here is my Java code :
 
try {
			HttpURLConnection sfdcConnection = (HttpURLConnection) new URL("https://cs61.salesforce.com/services/data/v39.0/sobjects/Product2/External_ID__c/1?_HttpMethod=PATCH").openConnection();
			
			sfdcConnection.setRequestMethod("POST");
			sfdcConnection.setDoOutput(true);
			sfdcConnection.setRequestProperty("Content-Type", "application/json");
			sfdcConnection.setRequestProperty("Accept", "application/json");
			sfdcConnection.setRequestProperty("Authorization", "Bearer token");
			
			DataOutputStream dts = new DataOutputStream(sfdcConnection.getOutputStream());
			dts.writeChars(JSONFile);
			
			BufferedReader br = new BufferedReader(new InputStreamReader(sfdcConnexion.getInputStream()));
			String result;
			if (sfdcConnection.getResponseCode() == 200) {
				while ((resultat = br.readLine()) != null) {
					System.out.println(resultat);
				}
			} else {
				System.out.println(sfdcConnection.getResponseCode());
			}
		} catch (Exception e) {
			System.out.println(e);
		}

Here is the JSON file :
{
	"records":[
		{"External_ID__c":"1","Name":"Product1"},
		{"External_ID__c":"2","Name":"Product2"}
	]
}

Thanks,
COFFIN Brandon
Maqsood AhmadMaqsood Ahmad
Hi Brandon

I'm also trying to implement multiple upserts through external id and haven't found a way.
Did you find any usefull way for multiple upserts through RESTfull API?

Thanks
Maqsood
Admin SVD Admin SVDAdmin SVD Admin SVD
Hi, I see that this post is a bit old.
But I wanted to give it a try in case any one solved it.
Thanks!