Is there a way to create a report for the failed entries while calling REST APIDelayed propagation when inserting data with the REST api?Creating a Person Account in Salesforce using the REST APIAccess the force.com REST API with a pure Javascript pageHow to create Live Agent Chat Invitation with REST APICreate/update multiple records using REST (Not Bulk API)How to return full report (>2000 rows) using rest api?Salesforce Rest API create accountDebug logs for failed REST API callsHow to check for duplicates while creating a record via Salesforce APIHow to expose REST API to external users — how do they authenticate and authorize to create lead in Salesforce

Should I self-publish my novella on Amazon or try my luck getting publishers?

Geometric programming: Why are the constraints defined to be less than/equal to 1?

sed delete all the words before a match

Ex-contractor published company source code and secrets online

Can an SPI slave start a transmission in full-duplex mode?

What is the idiomatic way of saying “he is ticklish under armpits”?

How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?

Does this smartphone photo show Mars just below the Sun?

During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?

Where to pee in London?

Pretty heat maps

Best gun to modify into a monsterhunter weapon?

Use of "When" in present vs "whenever"

Shabbat clothing on shabbat chazon

Colleagues speaking another language and it impacts work

Looking for a new job because of relocation - is it okay to tell the real reason?

In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?

How does The Fools Guild make its money?

In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?

Why should we care about syntactic proofs if we can show semantically that statements are true?

Does this Foo machine halt?

Team goes to lunch frequently, I do intermittent fasting but still want to socialize

Can a character who casts Shapechange and turns into a spellcaster use innate spellcasting to cast spells with a long casting time?

How to display a duet in lyrics?



Is there a way to create a report for the failed entries while calling REST API


Delayed propagation when inserting data with the REST api?Creating a Person Account in Salesforce using the REST APIAccess the force.com REST API with a pure Javascript pageHow to create Live Agent Chat Invitation with REST APICreate/update multiple records using REST (Not Bulk API)How to return full report (>2000 rows) using rest api?Salesforce Rest API create accountDebug logs for failed REST API callsHow to check for duplicates while creating a record via Salesforce APIHow to expose REST API to external users — how do they authenticate and authorize to create lead in Salesforce






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















We have implemented a REST API that user/vendors can use to submit contact in Salesforce. However, there are instances when the user sends the invalid payload/data that the API rejects right away, which does not create the contact in Salesforce. My question is, is there a way I can create a report in Salesforce that could give me a list of requests where someone tried calling/sending information to API and it failed or should the calling end can see this only?



Thanks










share|improve this question



















  • 1





    You can create a new object called API Errors in Salesforce and insert records to that object if any API calls fail. I'd also create a scheduled batch process that deletes these records after a certain period of time, otherwise your org is going to be filled with eventually-useless data. Then build a report off this object.

    – Drew Kennedy
    8 hours ago


















2















We have implemented a REST API that user/vendors can use to submit contact in Salesforce. However, there are instances when the user sends the invalid payload/data that the API rejects right away, which does not create the contact in Salesforce. My question is, is there a way I can create a report in Salesforce that could give me a list of requests where someone tried calling/sending information to API and it failed or should the calling end can see this only?



Thanks










share|improve this question



















  • 1





    You can create a new object called API Errors in Salesforce and insert records to that object if any API calls fail. I'd also create a scheduled batch process that deletes these records after a certain period of time, otherwise your org is going to be filled with eventually-useless data. Then build a report off this object.

    – Drew Kennedy
    8 hours ago














2












2








2








We have implemented a REST API that user/vendors can use to submit contact in Salesforce. However, there are instances when the user sends the invalid payload/data that the API rejects right away, which does not create the contact in Salesforce. My question is, is there a way I can create a report in Salesforce that could give me a list of requests where someone tried calling/sending information to API and it failed or should the calling end can see this only?



Thanks










share|improve this question














We have implemented a REST API that user/vendors can use to submit contact in Salesforce. However, there are instances when the user sends the invalid payload/data that the API rejects right away, which does not create the contact in Salesforce. My question is, is there a way I can create a report in Salesforce that could give me a list of requests where someone tried calling/sending information to API and it failed or should the calling end can see this only?



Thanks







rest-api






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









StudentStudent

18510 bronze badges




18510 bronze badges










  • 1





    You can create a new object called API Errors in Salesforce and insert records to that object if any API calls fail. I'd also create a scheduled batch process that deletes these records after a certain period of time, otherwise your org is going to be filled with eventually-useless data. Then build a report off this object.

    – Drew Kennedy
    8 hours ago













  • 1





    You can create a new object called API Errors in Salesforce and insert records to that object if any API calls fail. I'd also create a scheduled batch process that deletes these records after a certain period of time, otherwise your org is going to be filled with eventually-useless data. Then build a report off this object.

    – Drew Kennedy
    8 hours ago








1




1





You can create a new object called API Errors in Salesforce and insert records to that object if any API calls fail. I'd also create a scheduled batch process that deletes these records after a certain period of time, otherwise your org is going to be filled with eventually-useless data. Then build a report off this object.

– Drew Kennedy
8 hours ago






You can create a new object called API Errors in Salesforce and insert records to that object if any API calls fail. I'd also create a scheduled batch process that deletes these records after a certain period of time, otherwise your org is going to be filled with eventually-useless data. Then build a report off this object.

– Drew Kennedy
8 hours ago











2 Answers
2






active

oldest

votes


















4














Well, this is quite common requirement.
Lets assume a sample Rest Service.



@RestResource(urlMapping = '/submitcontact/*')
global class GenericContactCreator

@HttpPost
global static void doPost(Contact con) //Can be Sobject or some custom apex wrapper
//do something




If someone sends marformed JSON/XML the code wont even reach your apex class. The Java preporcessor will break it before hand. As code did not reach your apex code, you lost logging/debug logs



So what I do normally, is make rest method as parameterless, retrieve raw body from RestRequest



@RestResource(urlMapping = '/submitcontact/*')
global class GenericContactCreator

@HttpPost
global static void doPost()

String requestBOdy = RestContext.request.body.toString();
//The raw Request , LOG it, Parse it, your call. You have control to do it.




This gives you control to parse or log or do something about it. Also it removes the intimidating SF requirement of having outer layer of JSON /XML same as parameter name . In the above example con.






share|improve this answer



























  • +1 for the note on RestContext

    – identigral
    7 hours ago






  • 1





    using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

    – cropredy
    6 hours ago


















2














Out of the box, there is no report that tracks "failed" custom REST API calls.



Best practice is to create your own logging service (examples: 1 2) with one or more of your own custom objects that track any events of interest to you. Simple implementation: have a @future method or an event bus (Platform Events) asynchronously send a message to your logging service. You can then create a report against your own log entries. It's definitely valuable to have this on the Salesforce side because when a call fails, you'll have a record that you can use to resolve operational issues.



Salesforce does have an out of the box mechanism for tracking API calls, it's called Event Monitoring. It's an additional license and it's not cheap. Event Monitoring tracks quite a bit of stuff...but there's still no adequate out of the box reporting on top of that. Event Monitoring has an API-only interface that is designed for the use case of an external service consuming the event logs and then reporting/visualizing on events outside of SF. In the upcoming Winter '20 release of Salesforce, Event Monitoring will be able to distinguish custom REST API calls from other REST API calls. Salesforce built a really simple event log viewer but that won't help you, it treats all events generically. It won't show you enough detail (e.g. HTTP response status) for it to be operationally useful. You could grab the source of this log viewer and extend it to show you the desired fields.






share|improve this answer





























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f273074%2fis-there-a-way-to-create-a-report-for-the-failed-entries-while-calling-rest-api%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Well, this is quite common requirement.
    Lets assume a sample Rest Service.



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost(Contact con) //Can be Sobject or some custom apex wrapper
    //do something




    If someone sends marformed JSON/XML the code wont even reach your apex class. The Java preporcessor will break it before hand. As code did not reach your apex code, you lost logging/debug logs



    So what I do normally, is make rest method as parameterless, retrieve raw body from RestRequest



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost()

    String requestBOdy = RestContext.request.body.toString();
    //The raw Request , LOG it, Parse it, your call. You have control to do it.




    This gives you control to parse or log or do something about it. Also it removes the intimidating SF requirement of having outer layer of JSON /XML same as parameter name . In the above example con.






    share|improve this answer



























    • +1 for the note on RestContext

      – identigral
      7 hours ago






    • 1





      using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

      – cropredy
      6 hours ago















    4














    Well, this is quite common requirement.
    Lets assume a sample Rest Service.



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost(Contact con) //Can be Sobject or some custom apex wrapper
    //do something




    If someone sends marformed JSON/XML the code wont even reach your apex class. The Java preporcessor will break it before hand. As code did not reach your apex code, you lost logging/debug logs



    So what I do normally, is make rest method as parameterless, retrieve raw body from RestRequest



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost()

    String requestBOdy = RestContext.request.body.toString();
    //The raw Request , LOG it, Parse it, your call. You have control to do it.




    This gives you control to parse or log or do something about it. Also it removes the intimidating SF requirement of having outer layer of JSON /XML same as parameter name . In the above example con.






    share|improve this answer



























    • +1 for the note on RestContext

      – identigral
      7 hours ago






    • 1





      using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

      – cropredy
      6 hours ago













    4












    4








    4







    Well, this is quite common requirement.
    Lets assume a sample Rest Service.



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost(Contact con) //Can be Sobject or some custom apex wrapper
    //do something




    If someone sends marformed JSON/XML the code wont even reach your apex class. The Java preporcessor will break it before hand. As code did not reach your apex code, you lost logging/debug logs



    So what I do normally, is make rest method as parameterless, retrieve raw body from RestRequest



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost()

    String requestBOdy = RestContext.request.body.toString();
    //The raw Request , LOG it, Parse it, your call. You have control to do it.




    This gives you control to parse or log or do something about it. Also it removes the intimidating SF requirement of having outer layer of JSON /XML same as parameter name . In the above example con.






    share|improve this answer















    Well, this is quite common requirement.
    Lets assume a sample Rest Service.



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost(Contact con) //Can be Sobject or some custom apex wrapper
    //do something




    If someone sends marformed JSON/XML the code wont even reach your apex class. The Java preporcessor will break it before hand. As code did not reach your apex code, you lost logging/debug logs



    So what I do normally, is make rest method as parameterless, retrieve raw body from RestRequest



    @RestResource(urlMapping = '/submitcontact/*')
    global class GenericContactCreator

    @HttpPost
    global static void doPost()

    String requestBOdy = RestContext.request.body.toString();
    //The raw Request , LOG it, Parse it, your call. You have control to do it.




    This gives you control to parse or log or do something about it. Also it removes the intimidating SF requirement of having outer layer of JSON /XML same as parameter name . In the above example con.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 5 hours ago

























    answered 7 hours ago









    Pranay JaiswalPranay Jaiswal

    23.4k5 gold badges33 silver badges75 bronze badges




    23.4k5 gold badges33 silver badges75 bronze badges















    • +1 for the note on RestContext

      – identigral
      7 hours ago






    • 1





      using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

      – cropredy
      6 hours ago

















    • +1 for the note on RestContext

      – identigral
      7 hours ago






    • 1





      using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

      – cropredy
      6 hours ago
















    +1 for the note on RestContext

    – identigral
    7 hours ago





    +1 for the note on RestContext

    – identigral
    7 hours ago




    1




    1





    using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

    – cropredy
    6 hours ago





    using platform events to log it ensures that even if your apexrest class blows up with an uncaught exception, the log gets preserved

    – cropredy
    6 hours ago













    2














    Out of the box, there is no report that tracks "failed" custom REST API calls.



    Best practice is to create your own logging service (examples: 1 2) with one or more of your own custom objects that track any events of interest to you. Simple implementation: have a @future method or an event bus (Platform Events) asynchronously send a message to your logging service. You can then create a report against your own log entries. It's definitely valuable to have this on the Salesforce side because when a call fails, you'll have a record that you can use to resolve operational issues.



    Salesforce does have an out of the box mechanism for tracking API calls, it's called Event Monitoring. It's an additional license and it's not cheap. Event Monitoring tracks quite a bit of stuff...but there's still no adequate out of the box reporting on top of that. Event Monitoring has an API-only interface that is designed for the use case of an external service consuming the event logs and then reporting/visualizing on events outside of SF. In the upcoming Winter '20 release of Salesforce, Event Monitoring will be able to distinguish custom REST API calls from other REST API calls. Salesforce built a really simple event log viewer but that won't help you, it treats all events generically. It won't show you enough detail (e.g. HTTP response status) for it to be operationally useful. You could grab the source of this log viewer and extend it to show you the desired fields.






    share|improve this answer































      2














      Out of the box, there is no report that tracks "failed" custom REST API calls.



      Best practice is to create your own logging service (examples: 1 2) with one or more of your own custom objects that track any events of interest to you. Simple implementation: have a @future method or an event bus (Platform Events) asynchronously send a message to your logging service. You can then create a report against your own log entries. It's definitely valuable to have this on the Salesforce side because when a call fails, you'll have a record that you can use to resolve operational issues.



      Salesforce does have an out of the box mechanism for tracking API calls, it's called Event Monitoring. It's an additional license and it's not cheap. Event Monitoring tracks quite a bit of stuff...but there's still no adequate out of the box reporting on top of that. Event Monitoring has an API-only interface that is designed for the use case of an external service consuming the event logs and then reporting/visualizing on events outside of SF. In the upcoming Winter '20 release of Salesforce, Event Monitoring will be able to distinguish custom REST API calls from other REST API calls. Salesforce built a really simple event log viewer but that won't help you, it treats all events generically. It won't show you enough detail (e.g. HTTP response status) for it to be operationally useful. You could grab the source of this log viewer and extend it to show you the desired fields.






      share|improve this answer





























        2












        2








        2







        Out of the box, there is no report that tracks "failed" custom REST API calls.



        Best practice is to create your own logging service (examples: 1 2) with one or more of your own custom objects that track any events of interest to you. Simple implementation: have a @future method or an event bus (Platform Events) asynchronously send a message to your logging service. You can then create a report against your own log entries. It's definitely valuable to have this on the Salesforce side because when a call fails, you'll have a record that you can use to resolve operational issues.



        Salesforce does have an out of the box mechanism for tracking API calls, it's called Event Monitoring. It's an additional license and it's not cheap. Event Monitoring tracks quite a bit of stuff...but there's still no adequate out of the box reporting on top of that. Event Monitoring has an API-only interface that is designed for the use case of an external service consuming the event logs and then reporting/visualizing on events outside of SF. In the upcoming Winter '20 release of Salesforce, Event Monitoring will be able to distinguish custom REST API calls from other REST API calls. Salesforce built a really simple event log viewer but that won't help you, it treats all events generically. It won't show you enough detail (e.g. HTTP response status) for it to be operationally useful. You could grab the source of this log viewer and extend it to show you the desired fields.






        share|improve this answer















        Out of the box, there is no report that tracks "failed" custom REST API calls.



        Best practice is to create your own logging service (examples: 1 2) with one or more of your own custom objects that track any events of interest to you. Simple implementation: have a @future method or an event bus (Platform Events) asynchronously send a message to your logging service. You can then create a report against your own log entries. It's definitely valuable to have this on the Salesforce side because when a call fails, you'll have a record that you can use to resolve operational issues.



        Salesforce does have an out of the box mechanism for tracking API calls, it's called Event Monitoring. It's an additional license and it's not cheap. Event Monitoring tracks quite a bit of stuff...but there's still no adequate out of the box reporting on top of that. Event Monitoring has an API-only interface that is designed for the use case of an external service consuming the event logs and then reporting/visualizing on events outside of SF. In the upcoming Winter '20 release of Salesforce, Event Monitoring will be able to distinguish custom REST API calls from other REST API calls. Salesforce built a really simple event log viewer but that won't help you, it treats all events generically. It won't show you enough detail (e.g. HTTP response status) for it to be operationally useful. You could grab the source of this log viewer and extend it to show you the desired fields.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 8 hours ago

























        answered 8 hours ago









        identigralidentigral

        1,7749 silver badges15 bronze badges




        1,7749 silver badges15 bronze badges






























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f273074%2fis-there-a-way-to-create-a-report-for-the-failed-entries-while-calling-rest-api%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

            Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу