I have an Active Directory sync app which is using for internal purpose and its saving the data to SQL table feeding from Azure AD via Graph API. Along with its basic functionality, we are updating custom user profile properties using CSOM. But most of the time after some request processing, we are getting Error 429, Too many requests.
Is there any option of bulk update to update a set of (say 500/1000 profile) custom user profile properties in a single request? Please help me on this. If there is any other option, please suggest.
Thanks in advance.
Cause:
When a user exceeds usage limits or request frequency limits, SharePoint Online throttles any further requests from that user account for a short period.For requests including CSOM or REST calls, SharePoint Online returns HTTP status code 429 ("Too many requests") or 503 ("Server Too Busy") and the requests will fail.
Possible work arounds:
Please check if the response includes a Retry-After value .Please wait till that time and retry later . Making additional calls while receiving throttle before the reftry-after time period responses will extend the time it takes for your app to become unthrottled.
Note: Not all of the Microsoft Graph APIs provide a Retry-After
header. In this case have an initial wait period and keep increasing
it exponentially with each 429 response.
Make sure your app in azure ad has Sites.FullControl.All and User.ReadWrite.All permission scopes and grant admin consent . Also check the same in xml for FullControl in app permissions.
Try to select only those user profile properties that you need in the request and avoid which are not necessary.
Use JSON batching to combine multiple requests into a single batch request.
Try using ExecuteQueryAsync() instead of ExecuteQuery() or vice versa or ExecuteQueryWithIncrementalRetry .
Optional: try to use ExecuteQuery calls with Start-Sleep -Milliseconds 1000 statements, especially if calling it in a loop.
Otherwise please try with these powershell module references:
Bulk Update | so ref
update User Profile
Other references:
Azure AD Graph API-SO
Microsoft Graph throttling guidance | Microsoft Docs
429 error-SO ref
Related
Is there a Rest Api call I can make to get the Session Timeout Value under Session Settings in Salesforce ?
Org-level defaults are available in metadata API but it's SOAP based, you'd need to create "package.xml" file and retrieve https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_securitysettings.htm and search for sessionTimeout
And you might need an admin account to do it, mortals typically can't view setup and use such development APIs.
It's not terribly useful anyway because every profile can override the default (Profile -> Session Settings, Profile -> Password Policies). You want ProfileSessionSetting.
Metadata API might be the only way, I don't see anything that would suggest REST API or Tooling API expose this object. I don't see it in https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_profile_permissions.htm
Consider asking on https://salesforce.stackexchange.com/ too?
I am trying to figure out the most efficient way of interacting with Azure AD via Graph API when creating new users.
The problem is, i am importing a set of users from upload file. But before creating them in AD, i first get all the users from AD and the check if the username is already taken, if not i create the user.
What i am trying to understand, is it better to get all the users from AD at once or is it better to validate each user individually and make multiple calls to AD during the validation process?
Is there any resource i can refer to to get more insight on the issue?
If the amount of users you want to check is not large , you'd better check them with individual request rather than retrieving the entire user list from AAD .
You can use Microsoft Graph API get user operation:
https://graph.microsoft.com/v1.0/users/YourUPN
If user is not exist , it returns a 404 (not found). You can refer to document for getting access tokens to call Microsoft Graph . Code samples here are also for your reference .
I need to make an Apex Callout to Marketing Cloud when a Lead is created in Salesforce that matches certain criteria. I would like to use this MC Rest API - https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/key:Autoemail/send. The issue then is that I first need to authenticate with MC to get an Access Token to pass when making the above API call. Does anyone have a good way to persist the Access Token in a Salesforce org? I'm thinking of storing it in a Custom Setting and only updating it when an Apex callout goes to use it and sees that it's nearly 60 minutes old. Is anyone doing something similar? Thanks!
If you know that access token to external service can be expired and should be updated sometimes automatically, the better approach is which you choose - custom setting (or custom object for storing it).
If this token can be hardcoded one time and it will not be changed for a long period, you can checkout Authentication Settings for External Systems functionality.
I have developed a standard Google App Engine backend Application for my Android client. Now, there is search functionality in the App and during one request, I plan to return 20 results but I search for more in advanced(like 100) so that for the next hit, I will just search in these records and return. So, I need a mechanism to save these 80 records so that the same user might get them quickly.
I searched for it and found out that we can enable sessions in appengine-web.xml but all the session access has been done in doPost() and doGet() while my code is entirely Google's cloud endpoints.(like Spring)
Another thing is that I would like to persist the data both inside the Datastore and some cache(like Memcache).
My end goal is storing this data across search sessions. Is there any mechanism that will allow me to do this?
The usual approach here is to provide a code value in the response which the user can send in the next request to "continue" viewing the same results. This is called a "cursor".
For example, you might store the 80 records under some random key in your cache, and then send that random key to the user as part of the response. Then, when the user makes a new request including the key, you just the records and return them.
Cookie-based sessions don't usually work well with APIs; they introduce unnecessary statefulness.
I read somewhere that the Salesforce API has a 10 request limit. If we write code to integrate with Salesforce:
1. What is the risk of this limit
2. How can we write code to negate this risk?
My real concern is that I don't want to build our customer this great standalone website that integrates with Salesforce only to have user 11 and 12 kicked out to wait until requests 1-10 are complete?
Edit:
Some more details on the specifics of the limitation can be found at http://www.salesforce.com/us/developer/docs/api/Content/implementation_considerations.htm. Look at the section titled limits.
"Limits
There is a limit on the number of queries that a user can execute concurrently. A user can have up to 10 query cursors open at a time. If 10 QueryLocator cursors are open when a client application, logged in as the same user, attempts to open a new one, then the oldest of the 10 cursors is released. This results in an error in the client application.
Multiple client applications can log in using the same username argument. However, this increases your risk of getting errors due to query limits.
If multiple client applications are logged in using the same user, they all share the same session. If one of the client applications calls logout(), it invalidates the session for all the client applications. Using a different user for each client application makes it easier to avoid these limits.*"
Not sure which limit you're referring to, but the governor limits are all listed in the Apex documentation. These limits apply to code running in a given Apex transaction (i.e. in response to a trigger/web service call etc), so adding more users won't hurt you - each transaction gets its own allocation of resources.
There are also limits on the number of long-running concurrent API requests and total API calls in a day. Most of these are per-license, so, again, as the number of users rises, so do the limits.
Few comments on:
I don't want to build our customer this great standalone website that integrates with Salesforce only to have user 11 and 12 kicked out to wait until requests 1-10 are complete?
There are two major things you need to consider when planning real-time Sfdc integration beside the api call limits mentioned in the metadaddy's answer (and if you make a lot of queries it's easy to hit these limits):
Sfdc has routine maintainance outage periods.
Querying Sfdc will always be significantly slower than a querying local datasource.
You may want to consider a local mirror of you Sfdc data where you replicate your Sfdc data.
Cheers,
Tymek
All API usage limits are calculated over 24 hours period
Limits are applicable to whole organization. So if you have several users connecting through API all of them count against the same limit.
You get 1,000 API requests per each Salesforce user. Even Unlimited Editions is actually limited to 5,000.
If you want to check your current API usage status go to Your Name |
Setup | Company Profile | Company Information
You can purchase additional API calls
You can read more at Salesforce API Limits documentation