-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Having problems deleting file via REST api - getting 404 #1765
Comments
Just for reference, this is what I was trying to follow to delete the files. |
Could you post some parse server logs as well? Also, was this file originally created on api.parse.com? If so, you'll need to use api.parse.com to delete it. |
@drew-gross No these were created with the server hosted on Heroku. Here is the log of a delete request that fails:
And in this case, the
And if I hit that URL directly, it downloads the picture to my laptop. |
Thats a Heroku log. I need the Parse Server log. Set |
@drew-gross would that be in the Heroku Config Variables that I set that? Or in my index.js file where I'm calling new ParseServer() and pass that to it in the config object? |
In your |
@drew-gross Sorry for the noobness, but where will these logs appear after I add that flag? I assumed they would add more stuff to the application server log that I see on Heroku but nothing more is showing up there. |
That flag will cause every request and response to be logged. If there is nothing showing up, then there must be some other issue with your configuration. |
@drew-gross any idea how I can figure out what else may be wrong with the configuration? Here's the call that creates the new server object.
|
@drew-gross okay so I figured out the issue with verbose and I now have it working. When I call the code in question, I don't even see the DELETE request in the parse-server logs at all. I have this running locally and here is the exact code I'm running:
When I put a break point down in the error function, "a" is just an array and they all say error 404. Also, this is the exact output after I make that call, on the log:
So it's odd that the DELETE call is not even showing up in there. Am I calling it wrong with the Parse.Cloud.httpRequest method or something? And again, if I hit the values for fileUrl in my browser, it downloads the images I'm trying to delete so the path is correct. This is on the latest released version of parse-server, 2.2.10. |
That is not the correct way to delete files. Please check the docs or ask a question on Stack Overflow if you are having trouble, this repo is for reporting bugs in Parse Server. |
Well I was following this here: https://parse.com/docs/rest/guide/#files-deleting-files And this here to make the rest call from the cloud code: https://parse.com/questions/making-a-rest-call-from-within-cloud-code According to that, it says I can use Parse.Cloud.httpRequest to make REST calls, so I am not sure what you are referring to as that not the correct ways. Both of those have links to the docs and that is what I followed. |
@astanton have you solved the problem, I have similar problem. I used Parse.Cloud.httpRequest to make REST calls to delete photos, but always fails. |
@astanton how did you fix this problem? |
At long last, I determined why the endpoint was not working, and always returning a 404. The name of the request URL is very important! It's NOT the full file url as one would expect. For example, the full url of the files on my parse-server look like:
To get the /files endpoint to DELETE this file the request URL is:
So, when the docs mentioned "To delete a file, send a DELETE request to the files URL, postfixed with the name of the file", it's correct! You just need to get rid of that extra /xxxxxxxxx before the actual filename. Here's my working cloud code....
|
I think it may also have had to do with you using ngrok in the request instead of your actual server URL. |
@iatek you are right! remove the Application Id from file URL
|
I have some cloud code that I'm calling from my parse instance that is the following:
I'm getting the message
Request failed with response code 404
in the heroku log. I'm positive that the url exists that I'm passing in because I can hit it in my browser and it downloads the image that I am trying to delete.I'm also positive that my
process.env.APP_ID
andprocess.env.MASTER_KEY
are correct as well since I've printed those to the log as well and seen them.Is there another step that I'm missing here?
The text was updated successfully, but these errors were encountered: