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 (*)

  1. No preconditions

Steps to reproduce (*)

  1. Navigate to Stores -> Settings -> Configuration -> Customers -> Customers Configuration
  2. Set Show Prefix to be Required
  3. Reindex and Flush Cache
  4. 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 (*)

  1. Validation
  2. Response code 200 in case of success (Customer was created after the second request, but got 500 in the console).

Actual result (*)

  1. No validation. Code 500 on every request

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

@TomashKhamlai, @chohanbhagchand, If you include the "prefix" for the "customer": and the "addresses": the return code is 200 every time. The request is shown below:

curl -v -s -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","prefix":"Mr.","default_shipping":true,"default_billing":true}],"disable_auto_group_change":0,"extension_attributes":{"is_subscribed":false}},"password":"MetaFrame1"}' | json_pp