- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019
08:21 AM
03-22-2019
08:21 AM
Retrieving newsletter subscriber field from magento 2 API
Hello everyone, I have the code below... but it's not giving me the newsletter subscription status. Please assist.
$api = "rest/V1/customers/search";
$json = '
{
"search_criteria": {
"filter_groups": [
{
"filters": [
],
"filters": [
{
"field": "created_at",
"value": "' . $start . '",
"condition_type": "gt"
}
]
},
{
"filters": [
],
"filters": [
{
"field": "created_at",
"value": "' . $end . '",
"condition_type": "lt"
}
]
}
]
}
}';
$ch = curl_init(urldecode("https://www.example.com/index.php/" . $api . "?" . http_build_query(json_decode($json))))
I can see it on my dashboard, but the returned results are not showing this field!
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2019
06:35 AM
03-26-2019
06:35 AM
Re: Retrieving newsletter subscriber field from magento 2 API
Hi van_trinh,
You can try with this api end point:
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 } } }
Hope it helps!
if issue solved,Click Kudos & Accept as Solution
Thanks