How can I enable the PATCH method? Is this done in config or code?
As for config, I see in the REST module that all four request methods are allowed for my entity type. However, I am trying to PATCH to the jsonapi endpoint, and I get this error...
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: No route found for "PATCH /my_entity/my_type": Method Not Allowed (Allow: GET, POST, HEAD) in Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest() (line 148 of /var/www/drupal_staging/vendor/symfony/http-kernel/EventListener/RouterListener.php).
Please let me know where in the UI or code do I enable PATCH requests.
I am logged into my app with the super admin (uid=1) account, so this is probably not an issue in my Drupal permissions.
This issue might be related: https://www.drupal.org/project/drupal/issues/2938035 -- Except I'm not sure if it is related, because like I said, I am using the super admin account, so I don't see how field permissions could be an issue.
Thank you.
Comments
Comment #2
Wim LeersThe JSON API module (https://www.drupal.org/project/jsonapi) is not part of the core REST module.
I think you're trying to use https://www.drupal.org/project/restui for https://www.drupal.org/project/jsonapi. The JSON API module does not need any configuration; https://www.drupal.org/project/restui is not for the JSON API module, but for core's REST API.
Hopefully that clears things up!
Comment #3
arnoldbird CreditAttribution: arnoldbird commentedWim,
Thanks for the fast response, but I think you misunderstand the issue. I can't make a PATCH request. I recognize this is likely a core issue, so I have filed it under rest.module instead of the jsonapi module. I mention the latter only because it's the approach I'm most accustomed to lately. I have been using the jsonapi endpoints for my POSTs and GETs.
In any case, I do not know how to PATCH, and don't know why the log is telling me I can't PATCH -- especially since I am using the super admin account.
PS -- Please re-file this as a jsonapi issue, if you think that would make more sense. Initially, I guessed it was a core issue.
Comment #4
arnoldbird CreditAttribution: arnoldbird commentedComment #5
Wim LeersLet's try this again.
To which URL are you sending a
PATCH
request?Comment #6
arnoldbird CreditAttribution: arnoldbird commentedWim,
I have tried a variety of endpoints, including jsonapi and rest endpoints:
In addition to the above jsonapi endpoints, I also try the REST endpoints I see at /admin/config/services/rest -- The path looks like...
...so the REST UI shows me...
...and since the UI doesn't tell me whether I should express {my entity} as an id or uuid, I tried both.
For the REST endpoints, I am seeing "page not found" messages in the Drupal log. For the jsonapi endpoint, I get the "Method not allowed" error in the Drupal log.
Thanks again.
Comment #7
Wim Leers/my…
cannot possibly be a JSON API endpoint.This is not correct.
This is not correct. For JSON API,
/jsonapi/{entity type ID}--{bundle}/{uuid}
would be correct though.This may be correct. This would be a REST route. But it depends on the configuration of your REST route.
Comment #8
Wim LeersIt'd really be much easier to help you if you'd actually answer
Comment #9
arnoldbird CreditAttribution: arnoldbird commentedWim,
I figured you were referring to paths. My mistake. As for the URLs, here's one: https://theally.net/orb_activity/digital/a041a8f9-24e5-495c-a894-a055c76... -- Since this is a protected resource, you will see a 403 code in the response text.
I am using the json api extras module. The my_entity/my_type path is a jsonapi endpoint. That is, if I'm safe in assuming that all endpoints listed at admin/config/services/jsonapi are jsonapi endpoints.
The following is not a path in my system...
I get a "page not found" message in my log when I try to PATCH to that endpoint. However, when I patch to this...
I see nothing in the Drupal log. The item is not patched, but there is no error. FWIW, the preceding is indeed a jsonapi endpoint, according to the UI at admin/config/services/jsonapi. (That doesn't mean I think this is a jsonapi issue, of course.)
I think it might make sense to close this, as it looks like maybe I was getting the "Method Not Allowed" message appears when I try to PATCH to an endpoint to which it makes no sense to PATCH, such as one that has no UUID in the path. I thought maybe the UUID wasn't necessary in the path since the body of the request contains the UUID, but it looks like maybe it's needed in both body and path.
My remaining issue is that the PATCH request doesn't update any field values, but maybe that's something I should open as a separate issue.
PS -- I can now update (PATCH) values in my entity. I had been trying to update a paragraph field, but I switched to something simpler and it works. No issue with PATCH!
Comment #10
arnoldbird CreditAttribution: arnoldbird commentedComment #11
Katebg CreditAttribution: Katebg commentedHi All,
I'm having the same problem
Thanks in advance for your help....
Comment #12
wombatbuddy CreditAttribution: wombatbuddy commented@Katebg,
Visit /admin/config/services/jsonapi
and ensure that the following option is selected: "Accept all JSON:API create, read, update, and delete operations."
Comment #13
sam452 CreditAttribution: sam452 as a volunteer commentedPerhaps @arnoldbird could indicate what worked for his Paragraph entity in using PATCH? Particularly using subrequests.
My URL is /jsonapi/paragraph--address/myUUIDhash which does not allow PATCH.