How to create events observer that only call when REST api dispatch events?How to obtain a JSON order rendered by the REST API in the sales_order_place_after event observerCall observer function when stock inventory attribute updated programaticallyMagento 2.1.1 Rest API Update price onlyMagento 2 - Category Save Event is not called when save category via rest apiHow to get Product via API right after product created?Magento 2 rest API - How to Manage API Authentication Lifecycle on Mobile Devices Application?REST API - dispatch eventsHow to call dispatch events specific for Mobile?

Is God unknowable?

When does Tiana, Ship's Caretaker check card type?

Plotting octahedron inside the sphere and sphere inside the cube

Understanding the point of a kölsche Witz

Is there a standardised way to check fake news?

Is it feasible to get a hash collision for CRC32, MD-5 and SHA-1 on one file?

How much maintenance time did it take to make an F4U Corsair ready for another flight?

How to reduce Sinas Chinam

The cat ate your input again!

How to disable "Completion time:..." in SQL Server Messages window

Why command hierarchy, if the chain of command is standing next to each other?

If clocks themselves are based on light signals, wouldn't we expect the measured speed of light to always be the same constant?

A torrent of foreign terms

How far did Gandalf and the Balrog drop from the bridge in Moria?

TEMPO: play a sound in animated GIF/PDF/SVG

If "more guns less crime", how do gun advocates explain that the EU has less crime than the US?

Why is there a large performance impact when looping over an array over 240 elements?

How can I categorize files in a directory based on their content?

How to describe accents?

A continuous water "planet" ring around a star

Lengthened voiced stops and the airstream through the nose

How can this older-style irrigation tee be replaced?

Can a PC use the Levitate spell to avoid movement speed reduction from exhaustion?

What is this "Table of astronomy" about?



How to create events observer that only call when REST api dispatch events?


How to obtain a JSON order rendered by the REST API in the sales_order_place_after event observerCall observer function when stock inventory attribute updated programaticallyMagento 2.1.1 Rest API Update price onlyMagento 2 - Category Save Event is not called when save category via rest apiHow to get Product via API right after product created?Magento 2 rest API - How to Manage API Authentication Lifecycle on Mobile Devices Application?REST API - dispatch eventsHow to call dispatch events specific for Mobile?






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








2















I just want to call an event observer when the event is dispatch via REST API. Like if an order is placed from a mobile application, only then the sales_order_save_afterObserver should be called.

How to write code for same in events.xml? Or we have to write somewhere else?









share
































    2















    I just want to call an event observer when the event is dispatch via REST API. Like if an order is placed from a mobile application, only then the sales_order_save_afterObserver should be called.

    How to write code for same in events.xml? Or we have to write somewhere else?









    share




























      2












      2








      2








      I just want to call an event observer when the event is dispatch via REST API. Like if an order is placed from a mobile application, only then the sales_order_save_afterObserver should be called.

      How to write code for same in events.xml? Or we have to write somewhere else?









      share
















      I just want to call an event observer when the event is dispatch via REST API. Like if an order is placed from a mobile application, only then the sales_order_save_afterObserver should be called.

      How to write code for same in events.xml? Or we have to write somewhere else?







      magento2 event-observer rest





      share














      share












      share



      share








      edited 13 hours ago









      Daniel

      1,0821 gold badge3 silver badges19 bronze badges




      1,0821 gold badge3 silver badges19 bronze badges










      asked 14 hours ago









      Navin BhudiyaNavin Bhudiya

      9571 gold badge12 silver badges27 bronze badges




      9571 gold badge12 silver badges27 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          3














          You have to place a events.xml in the webapi_rest area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml



          By placing the events.xml in the webapi_restdirectory the observer only listens to events dispatched in that area.



          You can read about the areas and events in the devdocs.






          share|improve this answer


































            3














            You can declare your observer at following location to call it via REST api only.




            app/code/Vendor/Module/etc/webapi_rest/events.xml






            share



























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              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%2fmagento.stackexchange.com%2fquestions%2f285144%2fhow-to-create-events-observer-that-only-call-when-rest-api-dispatch-events%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









              3














              You have to place a events.xml in the webapi_rest area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml



              By placing the events.xml in the webapi_restdirectory the observer only listens to events dispatched in that area.



              You can read about the areas and events in the devdocs.






              share|improve this answer































                3














                You have to place a events.xml in the webapi_rest area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml



                By placing the events.xml in the webapi_restdirectory the observer only listens to events dispatched in that area.



                You can read about the areas and events in the devdocs.






                share|improve this answer





























                  3












                  3








                  3







                  You have to place a events.xml in the webapi_rest area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml



                  By placing the events.xml in the webapi_restdirectory the observer only listens to events dispatched in that area.



                  You can read about the areas and events in the devdocs.






                  share|improve this answer















                  You have to place a events.xml in the webapi_rest area: app/[Vendor]/[Module]/etc/webapi_rest/events.xml



                  By placing the events.xml in the webapi_restdirectory the observer only listens to events dispatched in that area.



                  You can read about the areas and events in the devdocs.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 13 hours ago

























                  answered 14 hours ago









                  DanielDaniel

                  1,0821 gold badge3 silver badges19 bronze badges




                  1,0821 gold badge3 silver badges19 bronze badges


























                      3














                      You can declare your observer at following location to call it via REST api only.




                      app/code/Vendor/Module/etc/webapi_rest/events.xml






                      share





























                        3














                        You can declare your observer at following location to call it via REST api only.




                        app/code/Vendor/Module/etc/webapi_rest/events.xml






                        share



























                          3












                          3








                          3







                          You can declare your observer at following location to call it via REST api only.




                          app/code/Vendor/Module/etc/webapi_rest/events.xml






                          share













                          You can declare your observer at following location to call it via REST api only.




                          app/code/Vendor/Module/etc/webapi_rest/events.xml







                          share











                          share


                          share










                          answered 14 hours ago









                          Dinesh YadavDinesh Yadav

                          4,3941 gold badge9 silver badges38 bronze badges




                          4,3941 gold badge9 silver badges38 bronze badges






























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento 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%2fmagento.stackexchange.com%2fquestions%2f285144%2fhow-to-create-events-observer-that-only-call-when-rest-api-dispatch-events%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

                              ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

                              Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

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