Is there a way to create a report for the failed entries while calling REST APIDelayed propagation when...

Why did the RAAF procure the F/A-18 despite being purpose-built for carriers?

Yajilin minicubes: the Hullabaloo, the Brouhaha, the Bangarang

What happen if I gain the control of aura that enchants an opponent's creature? Would the aura stay attached?

Can we use other things than single-word verbs in our dialog tags?

Is there a loss of quality when converting RGB to HEX?

Why are physicists so interested in irreps if in their non-block-diagonal form they mix all components of a vector?

What word can be used to describe a bug in a movie?

Replace data between quotes in a file

How to help new students accept function notation

Should I take out a personal loan to pay off credit card debt?

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

Tikzcd pullback square issue

Why should public servants be apolitical?

How to query data in backups?

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

Improving software when the author can see no need for improvement

Is refreshing multiple times a test case for web applications?

Are any jet engines used in combat aircraft water cooled?

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

Does this Foo machine halt?

Shabbat clothing on shabbat chazon

How does The Fools Guild make its money?

Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?

Double blind peer review when paper cites author's GitHub repo for code



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
    7 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
    7 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
    7 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
    7 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
7 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
7 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 7 hours ago

























        answered 7 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

            Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

            The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

            Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...