Programmatically update Webform Submission by sid I'm trying create/update Webform Submission programmatically. I already know how the create new submission by following the Drupal 8 API. Now I'm trying to build a update method, I refer to the Webform module source-code and API documents but couldn't find a solution. I guess they remove webform_get_submission webform_submission_update functions in Drupal 8.3 as-well.

$values = [
  'webform_id' =&gt; 'attendees_info',
  'in_draft' =&gt; FALSE,
  'uid' =&gt; $uid,
  'langcode' =&gt; 'en',
  'token' =&gt; 'at_'.$token,
  'uri' =&gt; '/webform/attendees/api',
  'remote_addr' =&gt; '',
  'data' =&gt; [
    'name' =&gt; $name,
    'email' =&gt; $email,
    'gallery_url' =&gt; 'gallery/'.$token,
  ],
];

$webform = Webform::load($values['webform_id']);
$is_open = WebformSubmissionForm::isOpen($webform);

if ($is_open === TRUE) {
    // Validate submission.
    $errors = WebformSubmissionForm::validateValues($values);

    // Check there are no validation errors.
    if (!empty($errors)) {
       return $errors;
    }
    else {
      // Submit values and get submission ID.
      $webform_submission = WebformSubmissionForm::submitValues($values);
      return $webform_submission-&gt;id();
    }
}


Above is my Submission creation code, I don't know how to do the update method. Is anyone face this issue before? Hope someone will help me on this, thanks.
Try using \Drupal\webform\WebformSubmissionInterface::getData(); and 
\Drupal\webform\WebformSubmissionInterface::setData($data);

// Load submission using sid.
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = \Drupal\webform\Entity\WebformSubmission::load($sid);

// Get submission data.
$data = $webform_submission-&gt;getData();

// Change submission data.
$data['element_key'] = 'custom_element_value';

// Set submission data.
$webform_submission-&gt;setData($data);

// Save submission.
$webform_submission-&gt;save();


Update: Use a capital "E" in "Entity" for the class name. (Recently got updated).