Вопрос

I try to register customer via Rest API. But customer registration Rest API throwing error.

Method: POST

Request URL: http://localhost/magento/rest/V1/customers

Body:

{
    "customer": {
        "email": "jdoea@example.com",
        "firstname": "Jane",
        "lastname": "Doe",
        "addresses": [{
            "defaultShipping": true,
            "defaultBilling": true,
            "firstname": "Jane",
            "lastname": "Doe",
            "region": {
                "regionCode": "NY",
                "region": "New York",
        "regionId":43
            },
            "postcode": "10755",
            "street": ["123 Oak Ave"],
            "city": "Purchase",
            "telephone": "512-555-1111",
            "countryId": "US"
        }]
    },
    "password": "test@$123"
}

Response:

    <br />
<b>Fatal error</b>: Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes) in
<b>/var/www/html/magento/vendor/magento/module-store/Model/StoreRepository.php</b> on line <b>74</b><br />
Это было полезно?

Решение

From my experience this kind of error is related to a recursive method that it calls upon itself in an infinite loop.

I would suggest to check the newest changes made to the project or the latest modules installed.

Другие советы

In case of anyone wondering, I've had the exact same issue in my Magento 2.3.5 multisite setup when calling the /rest/V1/customers REST endpoint.

I've solved the issue by specifying the store_id parameter in my customer object:

{
    "customer": {
        "firstname": "test",
        "lastname": "test",
        "email": "test@test.com",
        "store_id": 1,
        "extension_attributes": {
            "is_subscribed": false
        }
    },
    "password": "Account@123"
}

Change method GET to POST Pass Authentication key in header

Authorization: Bearer key

You can still use xdebug in Magento 2, but it will require modifying the default max_nesting_level value of 100 that xdebug uses.

Open up the php.ini file being used by your server and update or add the following config, depending on if it already exists in your file:

xdebug.max_nesting_level = 320

This works for me, but if you still see the error you can try doubling the value again.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top