## parameters
baseURL='https://apisalesdemo8.successfactors.com'
user='sfadmin'
compID='SFCPART000099'
pass="MySFpasswordHere"
## simple query
curl -u "$user@$compID:$pass" $baseURL'/odata/v2/User?$top=5&$format=json&&$select=country%2ClastName%2CuserId'
##with filter jq formatting
curl -s -u "$user@$compID:$pass" $baseURL'/odata/v2/User?$top=3&$format=json&&$select=country%2ChireDate%2ClastName%2CuserId&$filter=userId%20eq%20%27600002%27' | jq .
## Date example 1
curl -u "$user@$compID:$pass" $baseURL'/odata/v2/User?$top=3&$format=json&&$select=country%2ChireDate%2ClastName%2CuserId&$filter=lastModified%20ge%20%272022-05-31T00%3A22%3A08.252Z%27'
## Date example 2 (just date no time)
curl -u "$user@$compID:$pass" $baseURL'/odata/v2/User?$top=3&$format=json&&$select=country%2ChireDate%2ClastName%2CuserId&$filter=lastModified%20ge%20%272022-05-31%27'
## Date example Error, (report hireDate not filterable)
curl -u "$user@$compID:$pass" $baseURL'/odata/v2/User?$top=3&$format=json&&$select=country%2ChireDate%2ClastName%2CuserId&$filter=hireDate%20ge%20datetime%272022-05-31T00%3A22%3A08.252Z%27'
###Query: SAPSystemConfiguration object
curl -u "$user@$compID:$pass" $baseURL'/odata/v2/SAPSystemConfiguration?$format=json&$select=lastModifiedDateTime%2CexternalCode%2CcreatedBy%2ClastModifiedBy%2CcreatedDateTime&$inlinecount=allpages&paging=client&customPageSize=128'
Do not use the /oauth/idp API to generate SAML assertions. This approach is unsecure and has been deprecated. For more information, see the Related Information section.
###SF curl with OAuth example
apikey='MzU5N-------Removed------------3OTVlYw'
userid='sfadmin'
companyID="SFCPART000099"
urlBase='apisalesdemo8.successfactors.com'
tokenurl="https://$urlBase/oauth/token"
##from cert, downloaded from SF if generated in GUI of SF create app.
private_key='TUlJRXZRSUJBREFOQmdrc----removed---1NGQ1BBUlQwMDAwMjc='
##get Base64 encoded SAML assertion
samlassb64=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=$apikey&user_id=$userid&token_url=$tokenurl&private_key=$private_key" https://$urlBase/oauth/idp )
##view XML use below
#samlass=$(echo $samlassb64| base64 --decode)
#echo $samlass
## Request a User Token using the SAML Assertion
accessToken=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "company_id=$companyID&client_id=$apikey&grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer&assertion=$samlassb64" $tokenurl | jq .access_token)
##validate
curl -s -X GET -H "Authorization: Bearer $accessToken" https://$urlBase/oauth/validate | jq .
##use in call
curl -s -X GET -H "Authorization: Bearer $accessToken" "https://$urlBase/"'odata/v2/User?$top=3&$format=json&&$select=country%2ChireDate%2ClastName%2CuserId&$filter=userId%20eq%20%27600002%27' | jq .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |