Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Comment | File | Size | Author |
---|---|---|---|
#12 | webform_rest-3166084-11.patch | 2.54 KB | joaomarques736 |
#10 | webform_rest-3166084-10.patch | 2.53 KB | joaomarques736 |
Comments
Comment #2
mcventur CreditAttribution: mcventur commentedComment #3
mcventur CreditAttribution: mcventur commentedProblem/Motivation
When i send a PATCH request to my site to
/webform_rest/{webform_id}/submission/{sid}?_format=json
with the body
from postman, i've received a 500 error.
The site log displays the next error:
¿Am i making a bad request? What is the $webform_data argument? My webform has a field "sincronizado", of type value.
How to reproduce
Make any trying of pàtching submission with the /webform_rest/{webform_id}/submission/{sid} resource
Comment #4
mcventur CreditAttribution: mcventur commentedComment #5
mcventur CreditAttribution: mcventur commentedThe goal is read all submissions with "sincronizado" = 0 (GET from a view, i got it). And then, update these submissions with sincronizado = 1.
Comment #6
mcventur CreditAttribution: mcventur commentedIf i set a default value [] for $webform_data parameter in patch function on WebformSubmissionResource.php i get the response 200 with mesage
Comment #7
mcventur CreditAttribution: mcventur commentedSame problem sending sid parameter with Webform rest version 8.x-2.0-beta3.
My request exported from postman, in curl code is
Comment #8
mcventur CreditAttribution: mcventur commentedI have more info. I'm debuggin the problem and i've seen that it's generated in core/modules/rest/src/RequestHandler.php, in the delegateToRestResourcePlugin() function. Specifically in the call
$arguments = $argument_resolver->getArguments([$resource, $method]);
Then, it seems a core rest module bug, isn't it?
Comment #9
mcventur CreditAttribution: mcventur commentedComment #10
joaomarques736 CreditAttribution: joaomarques736 commentedHello mcventur,
I can't figure out why this worked on D8 but it is not working in D9.
Anyway, i fixed this with this patch.
Best regards.
Comment #11
joaomarques736 CreditAttribution: joaomarques736 commentedComment #12
joaomarques736 CreditAttribution: joaomarques736 commentedPatch with a small change in a comment
Comment #13
mcventur CreditAttribution: mcventur commentedIt works great! Thank you!
Adittional question: I have verified that it is not necessary to send the X-CSRF-Token to make a PATCH. ¿It's working as designed?
Comment #14
joaomarques736 CreditAttribution: joaomarques736 commentedNo problem!
I tested a PATCH in postman with drupal 9 and it appears "X-CSRF-Token request header is missing" as it is supposed. Can you show any evidence, the configurations you are using?
Best regards!
Comment #15
mcventur CreditAttribution: mcventur commentedThis is the curl code of the patch request:
And this is the response with 200 code:
{
"sid": "21c28b2e-cacd-484b-98cd-3f6265d65869"
}
Drupal 9.0.6 and Webform Rest 4.x-dev
Comment #16
joaomarques736 CreditAttribution: joaomarques736 commentedHello mcventur,
Ok, i confirmed that it is not necessary to send the X-CSRF-Token to make a PATCH when you are using "basic auth" (comparing with another REST Resources), so it is working as designed.
Thank you and best regards!
Comment #17
joaomarques736 CreditAttribution: joaomarques736 at NTT DATA commentedComment #18
ram4nd CreditAttribution: ram4nd as a volunteer commented