Skip to content

Instantly share code, notes, and snippets.

@sfdcale
Last active August 10, 2021 21:53
Show Gist options
  • Select an option

  • Save sfdcale/e3fc6902ad2437439f175ac8eb4ab9ce to your computer and use it in GitHub Desktop.

Select an option

Save sfdcale/e3fc6902ad2437439f175ac8eb4ab9ce to your computer and use it in GitHub Desktop.
Shortcut on how to read instance url and access token from SFDX CLI and use that in curl
sfdx force:org:display --targetusername sandbox --json | jq -r '[.result.instanceUrl,.result.accessToken] | @tsv' \
| xargs -t sh -c 'curl -i --location $1/services/data/v50.0/sobjects/ContentVersion \
--header "Authorization: Bearer $2" \
--form entity_content='\''{ "PathOnClient": "Statement.pdf" };type=application/json'\'' \
--form VersionData="@Metecho Training.pdf;type=application/octset-stream;"' sh
# Make sure that there is a file named `@Metecho Training.pdf` in the location where this command is run from.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment