magento2: [REST API] Argument 2 passed to Magento\Eav\Model\Attribute\Data\Text::validateLength() must be of the type string, null given
The server’s response code is 500 in cases either success or failure when Show Prefix is set to be required. Customer is created by setting prefix in Address section
Preconditions (*)
- No preconditions
Steps to reproduce (*)
- Navigate to Stores -> Settings -> Configuration -> Customers -> Customers Configuration
- Set Show Prefix to be Required
- Reindex and Flush Cache
- Send request:
### Set your endpoint name, example: endpoint="http://gql-ce.io/rest"
endpoint="REPLACE";
admin_token=$(curl -X POST "$endpoint/V1/integration/admin/token" \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"123123q"}') && echo $admin_token && admin_token=$(echo $admin_token | tr -d '"');
curl -X POST $endpoint/V1/customers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $admin_token" \
-d '{"customer":{"default_billing":"1","default_shipping":"1","email":"yhitecwa12@gmail.com","firstname":"Yokoshima","lastname":"Hiteca","gender": "3","store_id":1,"website_id":1,"addresses":[{"id":1,"region":{"region_code":"CA","region":"California","region_id":12},"region_id":12,"country_id":"US","street":["6161 West Centinela Avenue"],"company":"Magento","telephone":"555-55-555-55","postcode":"90230","city":"Culver City","firstname":"Yokoshima","lastname":"Hiteca","default_shipping":true,"default_billing":true}],"disable_auto_group_change":0,"extension_attributes":{"is_subscribed":false}},"password":"MetaFrame1"}' | json_pp
or
### Set your endpoint name, example: endpoint="http://gql-ce.io/rest"
endpoint="REPLACE";
admin_token=$(curl -X POST "$endpoint/V1/integration/admin/token" \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"123123q"}') && echo $admin_token && admin_token=$(echo $admin_token | tr -d '"');
curl -X POST $endpoint/V1/customers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $admin_token" \
-d '{"customer":{"default_billing":"1","default_shipping":"1","email":"yhitecwa12@gmail.com","firstname":"Yokoshima","lastname":"Hiteca","gender": "3","prefix":"Mr.","store_id":1,"website_id":1,"addresses":[{"id":1,"region":{"region_code":"CA","region":"California","region_id":12},"region_id":12,"country_id":"US","street":["6161 West Centinela Avenue"],"company":"Magento","telephone":"555-55-555-55","postcode":"90230","city":"Culver City","firstname":"Yokoshima","lastname":"Hiteca","default_shipping":true,"default_billing":true}],"disable_auto_group_change":0,"extension_attributes":{"is_subscribed":false}},"password":"MetaFrame1"}' | json_pp
Expected result (*)
- Validation
- Response code
200
in case of success (Customer was created after the second request, but got 500 in the console).
Actual result (*)
- No validation. Code 500 on every request
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (10 by maintainers)
@TomashKhamlai, @chohanbhagchand, If you include the
"prefix"
for the"customer":
and the"addresses":
the return code is200
every time. The request is shown below: