7

I'm looking for a way to monitor API calls. Specifically when an API update came through. We have a hosting service that sends trial user info to the SFDC lead object through the SFDC API. There are questions as to whether some of the calls are reaching SFDC. Is there a way to see API call details? Or a way to monitor failed API calls?

12

There is now the Event Monitoring API (Paid Feature). You can use this with the API EventType to get a complete log of all the calls that were made on a certain day. You can use the METHOD_NAME, USER_ID, CLIENT_ID to identify who and what was making each call.

Salesforce API Event Monitoring

I've put some additional details about this in Monitoring your Salesforce API usage

  • 1
    Holy cow answering a 4 year old question! – Adrian Larson Jul 1 '16 at 0:11
  • It's weird where Googling takes you. Came across this when making a blog post and realized the Event Monitoring API came out well after the question was originally asked. There are probably lots of questions lurking around where there is something new in that area. – Daniel Ballinger Jul 1 '16 at 0:37
  • 1
    Yep just reading the release notes and looking for relevant questions would probably yield a wealth of such answers. – Adrian Larson Jul 1 '16 at 0:41
  • 1
    I've found that I am taken 4 years in the past no matter what I google regarding Salesforce. – skaz Jun 1 '17 at 11:44
6

In case you need more general overview, it can be useful to see API Usage Report. You can find it under Reports->Administrative Reports->API Calls Made Within Last 7 Days. It helped me quickly locate a source of an excessive amount of API requests.

4

There is no specific log per API call. However, you can enable the debug log for the user that the application is using to log in as under Setup->Monitoring->Debug Log. That will track up to 20 API calls (or inserts, updates, deletions, VisualForce pages, etc..). If you're actively monitoring it you can continually click the reset link to reset the limit and capture more logs.

If that's more detail than you're looking for and the application logs in each time it needs to use the Web Service API (rather than maintaining a session) you can simply look at that user's login history at the bottom of the user page. Look for a login type that isn't "Application" or "Sync".

1

If Setup->Monitoring->Debug logs won't meet your needs, you can do a few things.

  1. Use an AppExchange Application to log items. http://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IZ5PEAW for example. There are a few items on the AppExchange that meet this requireemtn and are free.

  2. Build your own logging application. By combining Apex, Apex Triggers, Custom Objects, and SFDC Content or Documents you could build your own logging application. Your Apex Code could log the activities and persist to a custom object or document, etc.

0

If you have an active session started you can send an ajax request to the server just like the ApexCSIPage (Developer Console) does.

You can then parse the response into whatever report you want.

    Request URL:https://na9.salesforce.com/_ui/common/apex/debug/ApexCSIAPI
    Request Method:POST
    Status Code:200 OK


    Request Headers
    Accept:*/*
    Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-US,en;q=0.8
    Connection:keep-alive
    Content-Length:681
    Content-Type:application/x-www-form-urlencoded; charset=UTF-8
    Cookie:s_vi=[CS]v1|27BCFAA0050112C6-4000013080112CB5[CE]; web_core_geoCountry=us; HTPortal=%22%7B%27HTVersion%27%3A%20%272.0%27%7D%22; ApexCSIPageCookie=true; umps_clientId=364076-005E0000001JcFS; rememberUn=false; webact=%7B%22l_vdays%22%3A0%2C%22l_visit%22%3A1345049058716%2C%22session%22%3A1345058910089%2C%22l_search%22%3A%22%22%2C%22l_dtype%22%3A%22%22%2C%22l_page%22%3A%22SFDC%3Aus%3Alogin%22%2C%22counter%22%3A33%2C%22pv%22%3A1%2C%22f_visit%22%3A1343948212140%2C%22version%22%3A%22w172.1%22%2C%22developer%22%3A1343948212140%2C%22l_cloud%22%3A%22No%20Cloud%22%2C%22seg%22%3A%22customer%3Aus%22%2C%22customer%22%3A1344039343400%2C%22d%22%3A%2270130000000sUVv%22%7D; login=eric.talley@roundcorner.com.rc_connect; com.salesforce.LocaleInfo=us; oinfo=c3RhdHVzPUZSRUUmdHlwZT0zJm9pZD0wMERFMDAwMDAwMFppTE0=; sfdc_lv2=KxG83HmRj82pZgH6/8VmeaQGh3JcSEKazKnqlR327YjjlxoAwTMdZL4JugEcb9DQhgNzhuK04XPp/vR6ozLks9wJRr3qKuh0zGVSvmMIsabxlP8caB7jCRV0N4zlWLychwiM3diYYSnptp3OxEB7+70Ei2ZTi3b8reEpWshFjCWHYTdsPHRC/M1Fnra9kLfqUZo8Zta1RxVTBfxGkeRkRZI/ZYmGTITxSVMqBCiDXjjK1qwzdL+3XBFCGSfVGzczNMZPnpdlUMjiB6UFaPOGqvA/Gdl5Pu87vhaCD63i+0uYuhVe056tFomcU48Z1estPswdUiLRrIoaIxArV191ZlBGUZO/DThzEMg5rsqf6bPHgL2awX8cx/rsjIe17pPz4TEcl9TvNKJKu1Ir6sqaDaEA6SzTlSYRVlDSYMbcIWJEHDfsPo/5g9gti+DjvHSUI/FpsSUUGuVGLYWQVz9blGb7cSG1IjBipCLS53pkzVlZiMpnsWMY2P8NdxKfSMlEE=; disco=E:00DE0000000ZiLM:005E0000001JcFS:0; autocomplete=1; sid=00DE0000000ZiLM!ARwAQPohYMWG4oLkVRaDfPhsMq8LtStEpm4BVf5TjkihMwQrmqjaU1Ntik5NfwVlR4ovwOTB_xX7L1jFg3j7JwCrJ82cd9O.; sid_Client=0000001JcFS0000000ZiLM; clientSrc=173.160.27.73; oid=00DE0000000ZiLM; inst=APPE; lastlist=/01IE0000000R0EL?setupid=CustomObjects; setupopen=
    Host:na9.salesforce.com
    Origin:https://na9.salesforce.com
    Referer:https://na9.salesforce.com/_ui/common/apex/debug/ApexCSIPage
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
    X-Requested-With:XMLHttpRequest
  • I had a look at this Request using the Chrome developer console. What sort of information to you see in the response? It looks like it only contains new trace Ids (keyprefix 07L) – Daniel Ballinger Aug 15 '12 at 23:43
  • Ahh true, I didnt provide a full solution. you have to emulate the full functionality of the retrieval system to get the actual code. I just provided an example of the poller as a starting point. – ebt Aug 16 '12 at 0:08
  • This is equivalent to issuing this query using Tooling API: select id from ApexLog – dzh May 4 '17 at 4:34
  • yep, anyone reading this should look up the tooling API. emulating their private API's is unnecessary. – ebt May 6 '17 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.