How can i subscribe newsletter in Magento2 using REST API

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





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







up vote
5
down vote

favorite
2












I am developing react-native application. Is there any REST API for subscribe newsletter in Magento2.










share|improve this question



























    up vote
    5
    down vote

    favorite
    2












    I am developing react-native application. Is there any REST API for subscribe newsletter in Magento2.










    share|improve this question























      up vote
      5
      down vote

      favorite
      2









      up vote
      5
      down vote

      favorite
      2






      2





      I am developing react-native application. Is there any REST API for subscribe newsletter in Magento2.










      share|improve this question













      I am developing react-native application. Is there any REST API for subscribe newsletter in Magento2.







      magento2 rest-api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 1 at 5:00









      Pratap varma Penmetsa

      15710




      15710




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          0
          down vote













          By default, Magento Newsletter module not support any API. But you can develop you own custom API.



          Below link help to develop rest API:




          https://alankent.me/2015/07/24/creating-a-new-rest-web-service-in-magento-2/




          Also you can use check Action classes from the below path for basic functionality that you need to achieve in API:




          MAGE_ROOT_PATH/vendor/magento/module-newsletter/Controller/Subscriber/




          Edit:



          someone contributed for this on github. you can check using the below link:



          https://github.com/magento/magento2/issues/9233






          share|improve this answer





























            up vote
            0
            down vote













            1 Create a module Test_Demo



            2 Create webapi.xml




            app/code/Test/Demo/etc/webapi.xml




            <?xml version="1.0" ?>
            <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
            <route url="/V1/newsletter/" method="POST">
            <service class="TestDemoApiNewsLetterSubscriptionInterface" method="postNewsLetter"/>
            <resources>
            <resource ref="anonymous"/>
            </resources>
            <data>
            <parameter name="customer_id" force="true">%customer_id%</parameter>
            </data>
            </route>
            </routes>


            3 Create di.xml




            app/code/Test/Demo/etc/di.xml




            <?xml version="1.0" ?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
            <preference for="TestDemoApiNewsLetterSubscriptionInterface" type="TestDemoModelNewsLetterSubscription" />
            </config>


            4 Create Interface File




            app/code/Test/Demo/Api/NewsLetterSubscriptionInterface.php




            <?php
            /**
            * A Magento 2 module named Test/Demo
            * Copyright (C) 2018
            */

            namespace TestDemoApi;

            interface NewsLetterSubscriptionInterface


            /**
            * POST for newsletter api
            * @return string
            */

            public function postNewsLetter();





            5 Create model file



            app/code/Test/Demo/Model/NewsLetterSubscription.php



            <?php
            /**
            * A Magento 2 module named Test/Demo
            * Copyright (C) 2018
            *
            */

            namespace TestDemoModel;
            use MagentoCustomerApiCustomerRepositoryInterface as CustomerRepository;

            class NewsLetterSubscription implements TestDemoApiNewsLetterSubscriptionInterface


            /**
            * @var MagentoFrameworkAppRequestInterface
            */

            protected $_request;

            /**
            * @var MagentoStoreModelStoreManagerInterface
            */
            protected $storeManager;

            /**
            * @var CustomerRepository
            */
            protected $customerRepository;

            /**
            * @var MagentoNewsletterModelSubscriberFactory
            */
            protected $subscriberFactory;

            /**
            * @var MagentoNewsletterModelSubscriber
            */
            protected $_subscriber;

            /**
            * Initialize dependencies.
            * @param MagentoFrameworkAppRequestInterface $request
            * @param MagentoStoreModelStoreManagerInterface $storeManager
            * @param CustomerRepository $customerRepository
            * @param MagentoNewsletterModelSubscriberFactory $subscriberFactory
            * @param MagentoNewsletterModelSubscriber $subscriber
            */

            public function __construct(
            MagentoFrameworkAppRequestInterface $request,
            MagentoStoreModelStoreManagerInterface $storeManager,
            CustomerRepository $customerRepository,
            MagentoNewsletterModelSubscriberFactory $subscriberFactory,
            MagentoNewsletterModelSubscriber $subscriber
            )

            $this->_request = $request;
            $this->storeManager = $storeManager;
            $this->customerRepository = $customerRepository;
            $this->subscriberFactory = $subscriberFactory;
            $this->_subscriber = $subscriber;



            /**
            * @inheritdoc
            */

            public function postNewsLetter()

            $customerId = (string)$this->_request->getParam('customer_id');
            if ($customerId == null




            6 Open postman application and testing the same.



            Note: Here I am providing logic based on the customer Id. you can change the logic as per your requirement.






            share|improve this answer



























              up vote
              0
              down vote













              No need for any custom API, you can use the customer edit endpoint



              EndPoint = "/V1/customers/customer_id"

              Method = "PUT"

              Json =

              "customer":
              "id": customer_id,
              "email": "customer_email",
              "firstname": "customer_firstname",
              "lastname": "customer_lastname",
              "store_id": store_id,
              "website_id": website_id,
              "extension_attributes":
              "is_subscribed": true





              Please replace customer_id, customer_email, customer_firstname, customer_lastname, store_id, website_id with the customer information.



              this was tested and worked for me






              share|improve this answer




















                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',
                convertImagesToLinks: false,
                noModals: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                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%2f244484%2fhow-can-i-subscribe-newsletter-in-magento2-using-rest-api%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                0
                down vote













                By default, Magento Newsletter module not support any API. But you can develop you own custom API.



                Below link help to develop rest API:




                https://alankent.me/2015/07/24/creating-a-new-rest-web-service-in-magento-2/




                Also you can use check Action classes from the below path for basic functionality that you need to achieve in API:




                MAGE_ROOT_PATH/vendor/magento/module-newsletter/Controller/Subscriber/




                Edit:



                someone contributed for this on github. you can check using the below link:



                https://github.com/magento/magento2/issues/9233






                share|improve this answer


























                  up vote
                  0
                  down vote













                  By default, Magento Newsletter module not support any API. But you can develop you own custom API.



                  Below link help to develop rest API:




                  https://alankent.me/2015/07/24/creating-a-new-rest-web-service-in-magento-2/




                  Also you can use check Action classes from the below path for basic functionality that you need to achieve in API:




                  MAGE_ROOT_PATH/vendor/magento/module-newsletter/Controller/Subscriber/




                  Edit:



                  someone contributed for this on github. you can check using the below link:



                  https://github.com/magento/magento2/issues/9233






                  share|improve this answer
























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    By default, Magento Newsletter module not support any API. But you can develop you own custom API.



                    Below link help to develop rest API:




                    https://alankent.me/2015/07/24/creating-a-new-rest-web-service-in-magento-2/




                    Also you can use check Action classes from the below path for basic functionality that you need to achieve in API:




                    MAGE_ROOT_PATH/vendor/magento/module-newsletter/Controller/Subscriber/




                    Edit:



                    someone contributed for this on github. you can check using the below link:



                    https://github.com/magento/magento2/issues/9233






                    share|improve this answer














                    By default, Magento Newsletter module not support any API. But you can develop you own custom API.



                    Below link help to develop rest API:




                    https://alankent.me/2015/07/24/creating-a-new-rest-web-service-in-magento-2/




                    Also you can use check Action classes from the below path for basic functionality that you need to achieve in API:




                    MAGE_ROOT_PATH/vendor/magento/module-newsletter/Controller/Subscriber/




                    Edit:



                    someone contributed for this on github. you can check using the below link:



                    https://github.com/magento/magento2/issues/9233







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Oct 1 at 5:25

























                    answered Oct 1 at 5:08









                    Pankaj Pareek

                    2,25211235




                    2,25211235






















                        up vote
                        0
                        down vote













                        1 Create a module Test_Demo



                        2 Create webapi.xml




                        app/code/Test/Demo/etc/webapi.xml




                        <?xml version="1.0" ?>
                        <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
                        <route url="/V1/newsletter/" method="POST">
                        <service class="TestDemoApiNewsLetterSubscriptionInterface" method="postNewsLetter"/>
                        <resources>
                        <resource ref="anonymous"/>
                        </resources>
                        <data>
                        <parameter name="customer_id" force="true">%customer_id%</parameter>
                        </data>
                        </route>
                        </routes>


                        3 Create di.xml




                        app/code/Test/Demo/etc/di.xml




                        <?xml version="1.0" ?>
                        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                        <preference for="TestDemoApiNewsLetterSubscriptionInterface" type="TestDemoModelNewsLetterSubscription" />
                        </config>


                        4 Create Interface File




                        app/code/Test/Demo/Api/NewsLetterSubscriptionInterface.php




                        <?php
                        /**
                        * A Magento 2 module named Test/Demo
                        * Copyright (C) 2018
                        */

                        namespace TestDemoApi;

                        interface NewsLetterSubscriptionInterface


                        /**
                        * POST for newsletter api
                        * @return string
                        */

                        public function postNewsLetter();





                        5 Create model file



                        app/code/Test/Demo/Model/NewsLetterSubscription.php



                        <?php
                        /**
                        * A Magento 2 module named Test/Demo
                        * Copyright (C) 2018
                        *
                        */

                        namespace TestDemoModel;
                        use MagentoCustomerApiCustomerRepositoryInterface as CustomerRepository;

                        class NewsLetterSubscription implements TestDemoApiNewsLetterSubscriptionInterface


                        /**
                        * @var MagentoFrameworkAppRequestInterface
                        */

                        protected $_request;

                        /**
                        * @var MagentoStoreModelStoreManagerInterface
                        */
                        protected $storeManager;

                        /**
                        * @var CustomerRepository
                        */
                        protected $customerRepository;

                        /**
                        * @var MagentoNewsletterModelSubscriberFactory
                        */
                        protected $subscriberFactory;

                        /**
                        * @var MagentoNewsletterModelSubscriber
                        */
                        protected $_subscriber;

                        /**
                        * Initialize dependencies.
                        * @param MagentoFrameworkAppRequestInterface $request
                        * @param MagentoStoreModelStoreManagerInterface $storeManager
                        * @param CustomerRepository $customerRepository
                        * @param MagentoNewsletterModelSubscriberFactory $subscriberFactory
                        * @param MagentoNewsletterModelSubscriber $subscriber
                        */

                        public function __construct(
                        MagentoFrameworkAppRequestInterface $request,
                        MagentoStoreModelStoreManagerInterface $storeManager,
                        CustomerRepository $customerRepository,
                        MagentoNewsletterModelSubscriberFactory $subscriberFactory,
                        MagentoNewsletterModelSubscriber $subscriber
                        )

                        $this->_request = $request;
                        $this->storeManager = $storeManager;
                        $this->customerRepository = $customerRepository;
                        $this->subscriberFactory = $subscriberFactory;
                        $this->_subscriber = $subscriber;



                        /**
                        * @inheritdoc
                        */

                        public function postNewsLetter()

                        $customerId = (string)$this->_request->getParam('customer_id');
                        if ($customerId == null




                        6 Open postman application and testing the same.



                        Note: Here I am providing logic based on the customer Id. you can change the logic as per your requirement.






                        share|improve this answer
























                          up vote
                          0
                          down vote













                          1 Create a module Test_Demo



                          2 Create webapi.xml




                          app/code/Test/Demo/etc/webapi.xml




                          <?xml version="1.0" ?>
                          <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
                          <route url="/V1/newsletter/" method="POST">
                          <service class="TestDemoApiNewsLetterSubscriptionInterface" method="postNewsLetter"/>
                          <resources>
                          <resource ref="anonymous"/>
                          </resources>
                          <data>
                          <parameter name="customer_id" force="true">%customer_id%</parameter>
                          </data>
                          </route>
                          </routes>


                          3 Create di.xml




                          app/code/Test/Demo/etc/di.xml




                          <?xml version="1.0" ?>
                          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                          <preference for="TestDemoApiNewsLetterSubscriptionInterface" type="TestDemoModelNewsLetterSubscription" />
                          </config>


                          4 Create Interface File




                          app/code/Test/Demo/Api/NewsLetterSubscriptionInterface.php




                          <?php
                          /**
                          * A Magento 2 module named Test/Demo
                          * Copyright (C) 2018
                          */

                          namespace TestDemoApi;

                          interface NewsLetterSubscriptionInterface


                          /**
                          * POST for newsletter api
                          * @return string
                          */

                          public function postNewsLetter();





                          5 Create model file



                          app/code/Test/Demo/Model/NewsLetterSubscription.php



                          <?php
                          /**
                          * A Magento 2 module named Test/Demo
                          * Copyright (C) 2018
                          *
                          */

                          namespace TestDemoModel;
                          use MagentoCustomerApiCustomerRepositoryInterface as CustomerRepository;

                          class NewsLetterSubscription implements TestDemoApiNewsLetterSubscriptionInterface


                          /**
                          * @var MagentoFrameworkAppRequestInterface
                          */

                          protected $_request;

                          /**
                          * @var MagentoStoreModelStoreManagerInterface
                          */
                          protected $storeManager;

                          /**
                          * @var CustomerRepository
                          */
                          protected $customerRepository;

                          /**
                          * @var MagentoNewsletterModelSubscriberFactory
                          */
                          protected $subscriberFactory;

                          /**
                          * @var MagentoNewsletterModelSubscriber
                          */
                          protected $_subscriber;

                          /**
                          * Initialize dependencies.
                          * @param MagentoFrameworkAppRequestInterface $request
                          * @param MagentoStoreModelStoreManagerInterface $storeManager
                          * @param CustomerRepository $customerRepository
                          * @param MagentoNewsletterModelSubscriberFactory $subscriberFactory
                          * @param MagentoNewsletterModelSubscriber $subscriber
                          */

                          public function __construct(
                          MagentoFrameworkAppRequestInterface $request,
                          MagentoStoreModelStoreManagerInterface $storeManager,
                          CustomerRepository $customerRepository,
                          MagentoNewsletterModelSubscriberFactory $subscriberFactory,
                          MagentoNewsletterModelSubscriber $subscriber
                          )

                          $this->_request = $request;
                          $this->storeManager = $storeManager;
                          $this->customerRepository = $customerRepository;
                          $this->subscriberFactory = $subscriberFactory;
                          $this->_subscriber = $subscriber;



                          /**
                          * @inheritdoc
                          */

                          public function postNewsLetter()

                          $customerId = (string)$this->_request->getParam('customer_id');
                          if ($customerId == null




                          6 Open postman application and testing the same.



                          Note: Here I am providing logic based on the customer Id. you can change the logic as per your requirement.






                          share|improve this answer






















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            1 Create a module Test_Demo



                            2 Create webapi.xml




                            app/code/Test/Demo/etc/webapi.xml




                            <?xml version="1.0" ?>
                            <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
                            <route url="/V1/newsletter/" method="POST">
                            <service class="TestDemoApiNewsLetterSubscriptionInterface" method="postNewsLetter"/>
                            <resources>
                            <resource ref="anonymous"/>
                            </resources>
                            <data>
                            <parameter name="customer_id" force="true">%customer_id%</parameter>
                            </data>
                            </route>
                            </routes>


                            3 Create di.xml




                            app/code/Test/Demo/etc/di.xml




                            <?xml version="1.0" ?>
                            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                            <preference for="TestDemoApiNewsLetterSubscriptionInterface" type="TestDemoModelNewsLetterSubscription" />
                            </config>


                            4 Create Interface File




                            app/code/Test/Demo/Api/NewsLetterSubscriptionInterface.php




                            <?php
                            /**
                            * A Magento 2 module named Test/Demo
                            * Copyright (C) 2018
                            */

                            namespace TestDemoApi;

                            interface NewsLetterSubscriptionInterface


                            /**
                            * POST for newsletter api
                            * @return string
                            */

                            public function postNewsLetter();





                            5 Create model file



                            app/code/Test/Demo/Model/NewsLetterSubscription.php



                            <?php
                            /**
                            * A Magento 2 module named Test/Demo
                            * Copyright (C) 2018
                            *
                            */

                            namespace TestDemoModel;
                            use MagentoCustomerApiCustomerRepositoryInterface as CustomerRepository;

                            class NewsLetterSubscription implements TestDemoApiNewsLetterSubscriptionInterface


                            /**
                            * @var MagentoFrameworkAppRequestInterface
                            */

                            protected $_request;

                            /**
                            * @var MagentoStoreModelStoreManagerInterface
                            */
                            protected $storeManager;

                            /**
                            * @var CustomerRepository
                            */
                            protected $customerRepository;

                            /**
                            * @var MagentoNewsletterModelSubscriberFactory
                            */
                            protected $subscriberFactory;

                            /**
                            * @var MagentoNewsletterModelSubscriber
                            */
                            protected $_subscriber;

                            /**
                            * Initialize dependencies.
                            * @param MagentoFrameworkAppRequestInterface $request
                            * @param MagentoStoreModelStoreManagerInterface $storeManager
                            * @param CustomerRepository $customerRepository
                            * @param MagentoNewsletterModelSubscriberFactory $subscriberFactory
                            * @param MagentoNewsletterModelSubscriber $subscriber
                            */

                            public function __construct(
                            MagentoFrameworkAppRequestInterface $request,
                            MagentoStoreModelStoreManagerInterface $storeManager,
                            CustomerRepository $customerRepository,
                            MagentoNewsletterModelSubscriberFactory $subscriberFactory,
                            MagentoNewsletterModelSubscriber $subscriber
                            )

                            $this->_request = $request;
                            $this->storeManager = $storeManager;
                            $this->customerRepository = $customerRepository;
                            $this->subscriberFactory = $subscriberFactory;
                            $this->_subscriber = $subscriber;



                            /**
                            * @inheritdoc
                            */

                            public function postNewsLetter()

                            $customerId = (string)$this->_request->getParam('customer_id');
                            if ($customerId == null




                            6 Open postman application and testing the same.



                            Note: Here I am providing logic based on the customer Id. you can change the logic as per your requirement.






                            share|improve this answer












                            1 Create a module Test_Demo



                            2 Create webapi.xml




                            app/code/Test/Demo/etc/webapi.xml




                            <?xml version="1.0" ?>
                            <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
                            <route url="/V1/newsletter/" method="POST">
                            <service class="TestDemoApiNewsLetterSubscriptionInterface" method="postNewsLetter"/>
                            <resources>
                            <resource ref="anonymous"/>
                            </resources>
                            <data>
                            <parameter name="customer_id" force="true">%customer_id%</parameter>
                            </data>
                            </route>
                            </routes>


                            3 Create di.xml




                            app/code/Test/Demo/etc/di.xml




                            <?xml version="1.0" ?>
                            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                            <preference for="TestDemoApiNewsLetterSubscriptionInterface" type="TestDemoModelNewsLetterSubscription" />
                            </config>


                            4 Create Interface File




                            app/code/Test/Demo/Api/NewsLetterSubscriptionInterface.php




                            <?php
                            /**
                            * A Magento 2 module named Test/Demo
                            * Copyright (C) 2018
                            */

                            namespace TestDemoApi;

                            interface NewsLetterSubscriptionInterface


                            /**
                            * POST for newsletter api
                            * @return string
                            */

                            public function postNewsLetter();





                            5 Create model file



                            app/code/Test/Demo/Model/NewsLetterSubscription.php



                            <?php
                            /**
                            * A Magento 2 module named Test/Demo
                            * Copyright (C) 2018
                            *
                            */

                            namespace TestDemoModel;
                            use MagentoCustomerApiCustomerRepositoryInterface as CustomerRepository;

                            class NewsLetterSubscription implements TestDemoApiNewsLetterSubscriptionInterface


                            /**
                            * @var MagentoFrameworkAppRequestInterface
                            */

                            protected $_request;

                            /**
                            * @var MagentoStoreModelStoreManagerInterface
                            */
                            protected $storeManager;

                            /**
                            * @var CustomerRepository
                            */
                            protected $customerRepository;

                            /**
                            * @var MagentoNewsletterModelSubscriberFactory
                            */
                            protected $subscriberFactory;

                            /**
                            * @var MagentoNewsletterModelSubscriber
                            */
                            protected $_subscriber;

                            /**
                            * Initialize dependencies.
                            * @param MagentoFrameworkAppRequestInterface $request
                            * @param MagentoStoreModelStoreManagerInterface $storeManager
                            * @param CustomerRepository $customerRepository
                            * @param MagentoNewsletterModelSubscriberFactory $subscriberFactory
                            * @param MagentoNewsletterModelSubscriber $subscriber
                            */

                            public function __construct(
                            MagentoFrameworkAppRequestInterface $request,
                            MagentoStoreModelStoreManagerInterface $storeManager,
                            CustomerRepository $customerRepository,
                            MagentoNewsletterModelSubscriberFactory $subscriberFactory,
                            MagentoNewsletterModelSubscriber $subscriber
                            )

                            $this->_request = $request;
                            $this->storeManager = $storeManager;
                            $this->customerRepository = $customerRepository;
                            $this->subscriberFactory = $subscriberFactory;
                            $this->_subscriber = $subscriber;



                            /**
                            * @inheritdoc
                            */

                            public function postNewsLetter()

                            $customerId = (string)$this->_request->getParam('customer_id');
                            if ($customerId == null




                            6 Open postman application and testing the same.



                            Note: Here I am providing logic based on the customer Id. you can change the logic as per your requirement.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Oct 1 at 6:57









                            Nagaraju Kasa

                            2,25011034




                            2,25011034




















                                up vote
                                0
                                down vote













                                No need for any custom API, you can use the customer edit endpoint



                                EndPoint = "/V1/customers/customer_id"

                                Method = "PUT"

                                Json =

                                "customer":
                                "id": customer_id,
                                "email": "customer_email",
                                "firstname": "customer_firstname",
                                "lastname": "customer_lastname",
                                "store_id": store_id,
                                "website_id": website_id,
                                "extension_attributes":
                                "is_subscribed": true





                                Please replace customer_id, customer_email, customer_firstname, customer_lastname, store_id, website_id with the customer information.



                                this was tested and worked for me






                                share|improve this answer
























                                  up vote
                                  0
                                  down vote













                                  No need for any custom API, you can use the customer edit endpoint



                                  EndPoint = "/V1/customers/customer_id"

                                  Method = "PUT"

                                  Json =

                                  "customer":
                                  "id": customer_id,
                                  "email": "customer_email",
                                  "firstname": "customer_firstname",
                                  "lastname": "customer_lastname",
                                  "store_id": store_id,
                                  "website_id": website_id,
                                  "extension_attributes":
                                  "is_subscribed": true





                                  Please replace customer_id, customer_email, customer_firstname, customer_lastname, store_id, website_id with the customer information.



                                  this was tested and worked for me






                                  share|improve this answer






















                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    No need for any custom API, you can use the customer edit endpoint



                                    EndPoint = "/V1/customers/customer_id"

                                    Method = "PUT"

                                    Json =

                                    "customer":
                                    "id": customer_id,
                                    "email": "customer_email",
                                    "firstname": "customer_firstname",
                                    "lastname": "customer_lastname",
                                    "store_id": store_id,
                                    "website_id": website_id,
                                    "extension_attributes":
                                    "is_subscribed": true





                                    Please replace customer_id, customer_email, customer_firstname, customer_lastname, store_id, website_id with the customer information.



                                    this was tested and worked for me






                                    share|improve this answer












                                    No need for any custom API, you can use the customer edit endpoint



                                    EndPoint = "/V1/customers/customer_id"

                                    Method = "PUT"

                                    Json =

                                    "customer":
                                    "id": customer_id,
                                    "email": "customer_email",
                                    "firstname": "customer_firstname",
                                    "lastname": "customer_lastname",
                                    "store_id": store_id,
                                    "website_id": website_id,
                                    "extension_attributes":
                                    "is_subscribed": true





                                    Please replace customer_id, customer_email, customer_firstname, customer_lastname, store_id, website_id with the customer information.



                                    this was tested and worked for me







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered yesterday









                                    WISAM HAKIM

                                    1,415617




                                    1,415617



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f244484%2fhow-can-i-subscribe-newsletter-in-magento2-using-rest-api%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Popular posts from this blog

                                        How to check contact read email or not when send email to Individual?

                                        Bahrain

                                        Postfix configuration issue with fips on centos 7; mailgun relay