![]() |
Error Put method from App in reactNative an RESTAPI CI4 - 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: Error Put method from App in reactNative an RESTAPI CI4 (/showthread.php?tid=79432) |
Error Put method from App in reactNative an RESTAPI CI4 - mailitos - 06-14-2021 Hello, I am developing a rest api with CI4, and consuming it with an app in reactNative, so far without problems with get methods, now when I want to update a record by sending a PUT it returns an error ( 405 Method Not Allowed)... I am going to clarify certain things: if I try to do the PUT from my client using the local development url everything works correctly, but the question is that my app connects through ngrok since I cannot connect it directly to the localhost, so there if the error of method not allowed ... I've read about cors / heads and others ... but I can't find the solution. I leave some images to verify that the error is not in my code but that somehow CI is blocking the request ... any idea how to solve this? .. thanks in advance RE: Error Put method from App in reactNative an RESTAPI CI4 - rmcdahal - 06-14-2021 If you are on shared hosting, then put, delete verbs may be disabled, I have got the same issue, after switching to cloud all working fine. RE: Error Put method from App in reactNative an RESTAPI CI4 - paliz - 06-14-2021 See this https://codeigniter.com/user_guide/incoming/methodspoofing.html form action="" method="post"> <input type="hidden" name="_method" value="PUT" /> </form> If you send json you should { "_method" :"PUT" } RE: Error Put method from App in reactNative an RESTAPI CI4 - InsiteFX - 06-15-2021 If it is a CORS problem I use this in my .htaccess file in the root with index.php Code: ## For CORS Configuration RE: Error Put method from App in reactNative an RESTAPI CI4 - mailitos - 06-15-2021 (06-14-2021, 10:51 PM)paliz Wrote: See this Thanks for your help, but I make my request from an app in react I don't have a form to do that ... that is, my call is directly from javascript with axios RE: Error Put method from App in reactNative an RESTAPI CI4 - paliz - 06-16-2021 Look i used angular 11 and send json to backend and i add this { "_method" :"PUT" } and other data wll send to backend with put request okay If multi part form data to should add formdata. Add(_method, put) with files itll send to backend and request must be post http |