1

When i send a PATCH request to my site to /webform_rest/{webform_id}/submission/{sid}?_format=json with the body

{
    "data":{
        "sincronizado":1
    }
}

or

{
  "sincronizado":1
}

from postman, I receive a 500 error.

The site log displays the next error:

RuntimeException: Callable "Drupal\webform_rest\Plugin\rest\resource\WebformSubmissionResource::patch" requires a value for the "$webform_data" argument. en Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument() (line 142 of /usr/home/example.com/web/core/lib/Drupal/Component/Utility/ArgumentsResolver.php).

Am I making a bad request? What is the $webform_data argument? My webform has a field "sincronizado", of type value.

I'm using Drupal 9. REST UI 8.x-1.18. RESTful Web Services 9.0.2 Webform 6.0.0-alpha12 Webform Rest 4.0.0-beta1


Same problem sending sid parameter with Webform rest version 8.x-2.0-beta3.

My request from postman, in curl code is

curl --location --request PATCH 'http://example.com/webform_rest/webform-id-example/submission/36?_format=json' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic (admin user and password in base 64)' \ --data-raw '{ "sincronizado":"1" }'

1 Answer 1

0

Ok mate if you open up webform_rest\Plugin\rest\resource\WebformSubmissionResource.php

and find the patch method you will see

public function patch($webform_id, $uuid, array $webform_data) { ...

looks like Webform Rest 4.0.0-beta1 is now using the submission uuid so

/webform_rest/{webform_id}/submission/{sid}

"sid" should now be Webform Submission UUID

for the body field or the $webform_data

the module is looking for

  foreach ($webform_data as $field => $value) {
      $webform_submission->setElementData($field, $value);
    }

so your json should look like:

   {
    "filed_name": "value"
   }

because json_decode($json_string, true) will return an array.

if that does not work then file a bug ticket

1
  • Thanks. I had seen the uuid parameter in the patch function. I've tested with uuid and with { "sincronizado":1} and { "sincronizado":"1"}, but ever with same result. The problem is that the patch function is not receiving the $webform_data parameter. If i set a default value [] for $webform_data parameter in patch function on WebformSubmissionResource.php i get the response 200 with message >{ > "error": { > "message": "No data has been submitted." > } >} I've sent and issue on the module project page: drupal.org/project/webform_rest/issues/3166084
    – mcventur
    Aug 21, 2020 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.