Created
August 25, 2014 16:36
-
-
Save richardvanhook/b128e0a44a59595832e4 to your computer and use it in GitHub Desktop.
Insert new account and attachment thru salesforce.com REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# REPLACE THE FOLLOWING VALUES | |
USERNAME=XXXXXXXXXXXXXXXXX | |
PASSWORD=XXXXXXXXXXXXXXXXX | |
# LOGIN | |
curl https://login.salesforce.com/services/Soap/u/31.0 -H "Content-Type: text/xml; charset=UTF-8" -H "SOAPAction: login" -d "<Envelope xmlns=\""http://schemas.xmlsoap.org/soap/envelope/\""><Header/><Body><login xmlns=\""urn:partner.soap.sforce.com\""><username>$USERNAME</username><password>$PASSWORD</password></login></Body></Envelope>" | |
# INSPECT RESPONSE AND SET FOLLOWING VALUES | |
# DOMAIN SHOULD BE na1, acme.my, etc | |
DOMAIN=na1 | |
# MAKE SURE TOKEN HAS SINGLE QUOTES AROUND IT | |
TOKEN='XXXXXXXXXXXXXXXXX' | |
# CREATE NEW ACCOUNT | |
curl "https://$DOMAIN.salesforce.com/services/data/v31.0/sobjects/Account/" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"Name" : "ABC 123 Account"}' | |
# INSPECT RESPONSE, REPLACE FOLLOWING WITH NEW ID | |
ACCOUNT_ID=XXXXXXXXXXXXXXXXX | |
# CREATE ACCOUNT ATTACHMENT, FILE IS TEXT abc123 | |
curl "https://$DOMAIN.salesforce.com/services/data/v31.0/sobjects/Attachment/" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "{\""ParentId\"":\""$ACCOUNT_ID\"",\""Name\"":\""abc123.txt\"",\""Body\"":\""YWJjMTIz\""}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment