cancel
Showing results for 
Search instead for 
Did you mean: 

There is no webapi resource for newsletter registration

0 Kudos

There is no webapi resource for newsletter registration

Feature request from degaray, posted on GitHub Jan 04, 2017

Preconditions

As of Magento 2.1 there is no endpoint in the webapi to subscribe to the newsletter.

Expected result

  1. There should be a post method to subscribe an email to the newsletter.
1 Comment
apiuser
New Member

Comment from misha-kotov, posted on GitHub Jan 27, 2017

Hi @degaray , you can currently subscribe/unsubscribe customers to the newsletter via the Customer resource. You PUT something like the following, specifying the extension_attribute is_subscribed:

{"customer": 
  {
    "id": 2,
    "group_id": 1,
    "default_billing": "0",
    "default_shipping": "0",
    "created_at": "2017-01-10 16:32:32",
    "updated_at": "2017-01-27 15:27:33",
    "created_in": "Default Store View",
    "email": "customer@example.com",
    "firstname": "FirstName",
    "lastname": "LastName",
    "store_id": 1,
    "website_id": 1,
    "addresses": [],
    "disable_auto_group_change": 0,
    "extension_attributes": {
      "is_subscribed": true
    }
  }
}

There's an issue currently reading this extension attribute on GET. The problem is that the plugin for the Customer module does not express how to populate this newsletter extension attribute data on a GET of a customer resource, hence it's missing from the response. The missing function needs to be defined here: <magento dir>/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php