I have successfully created node programmatically using Drupal 8 Node::create and be able to select list (integer) field correctly as following, but list (text) field is not getting selected with the same process. Any help appreciated.
(Manage Fields)
LABEL MACHINE NAME FIELD TYPE
===========================
Expires (in Days) field_expires_in_days_ List (integer) -> NOT WORKING
Item Type field_item_type List (text) - Working
Allowed value list for 'field_expires_in_days_
30|30
60|60
90|90
Allowed value list for 'field_item_type'
tipsheet|Tip Sheet
fyi|FYI
video|Video
(Controller)
$newListItem = array(); //prepare new item
$newListItem["title"] = "Title 111";
$newListItem["summary"] = "Some description";
$newListItem["itemType"] = "tipsheet";
$newListItem["expiresInDays"] = "30";
$node = Node::create([
'type' => 'custom_content_type',
'status' => 1,
'title' => $listItem['title'],
'body' => $listItem['summary'],
'field_item_type ' => $listItem['itemType'],
'field_expires_in_days_' => $listItem['expiresInDays'],
]);
$node->save();