1

We have an API that we are querying through React Native.

GET, POST request work flawlessly either in our app or in Postman.

DELETE doesn't work on the App, but the same request works with Postman.

What is even weirder is that :

If we delete the resource either with Django or Postman, making the exact same request from our app on the phone will give us a 404 response, telling us that indeed, it was deleted.

Which means that the call from our app is supposed to work since we get an answer from the API!

So, basically, the DELETE doesn't work from the app but if we delete the resource from elsewhere, it acts as if it works for real.

We tested it from two different phones, just in case... And we are using Expo.

Example of our DELETE request :

https://apiurl/reservations/id_num {"method":"DELETE","headers":{"Accept":"application/json","Content-Type":"application/json","X-App-Token":"blablatoken","Authorization":"JWT blablasuperlongtoken"}}

UPDATE: The question asked by MattyK14 was good, we get a 200 response which is supposed to be our GET response. We investigated on this path but can't seem to find anything.

We are rebuilding the API using Axios as we can't find a thing and we will check.

  • In your example https://apiurl/reservations/id_num how does your apiurl looks like? are you using localhost? try to use an ip address instead.. e.g https://127.0.0.1/reservations/id_num – Arman Ortega May 30 '17 at 15:58
  • What's the response on the app? – MattyK14 May 30 '17 at 16:24
  • @ArmanOrtega : It's a real apiurl pointing to our server. It's not localhost. Matty : we get a 200 response while our DELETE is supposed to give us a 204. – A Bit Masked Programmer May 30 '17 at 19:38
  • FOUND THE ERROR! We needed to add a trailing slash at the end of the API URL. Django automatically transforms your DELETE request into a GET request if it doesn't get a trailing slash. Thank you for your comments Matty and Arman. – A Bit Masked Programmer May 31 '17 at 16:17

1 Answers1

5

FOUND THE ERROR!

We needed to add a trailing slash at the end of the API URL. Django automatically transforms your DELETE request into a GET request if it doesn't get a trailing slash. Thank you for your comments Matty and Arman.