CodeIgniter Forums
REST does not support PATCH!? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: REST does not support PATCH!? (/showthread.php?tid=80667)



REST does not support PATCH!? - blaasvaer - 11-29-2021

From the docs it seems that PATCH redirect to PUT (as well as PUT itself) ... as if PATCH by itself is not supported. Why is that? And how would I make it support it?
I need different handling for the two ...


RE: REST does not support PATCH!? - kenjis - 11-29-2021

> PATCH redirect to PUT

No, a PATCH request is routed to the same method as a PUT request.

> Why is that?

Maybe the both of them are updating something.

> I need different handling for the two ...

PHP Code:
if ($this->request->getMethod() === 'patch') {
    return $this->patch(...);
} else {
    return $this->post(...);




RE: REST does not support PATCH!? - InsiteFX - 11-30-2021

This is a good read on it.

Use of PUT vs PATCH methods in REST API real life scenarios


RE: REST does not support PATCH!? - blaasvaer - 12-03-2021

Yes, I did all the reading I could find. It didn't leave me that much wiser to be honest.
What I'm basically struggling with is the issue of setting a datetime-local input to NULL, but when serializing the data on the front end, the value simply turns into an empty string (?published_at=) or no value (which again gets received on the server as an empty string). I guess a datetime-local input cannot be set to null, as it is: value="" (empty string).
Now, I need to pass null to the DB in order for the published_at timestamp field to be 'empty' (NULL – default). But since the CI Rest won't let me fiddle with the value on the server ... as it is a black box, I cannot check for the key 'published_at' and set it accordingly as I do in my nodejs version. I'm trying to fix it at the front end level, but still haven't found a way around the serialize problem which will always turn value="" into an empty string in the serialized output.

Christ, I ALWAYS seem to tick the wrong button below for getting notifications, UX, anyone?