0

I am using GAE Python (with the webapp2 framework) and AngularJS.

I am have trouble with routes on GAE. In fact I have an action in Angular $resource that allows to delete an object in my datastore.

Here's my Angular $resource code:

deleteImage :
        {
            method      : 'DELETE',
            isArray     :  false,
            format      : '.json',
            url         : '/api/hairdressers/:hrd_id/images/:ima_id',
            params      :
            {
            }
        },

When I'm calling this method, that calls this url with the DELETE verb :

mysite.com/api/hairdresser/877848/images/5451681

In my backend I have a route like :

webapp2.Route(r'/api/hairdressers/<hrd_id:(\d+)>/images/<ima_id:(\d+)>', handler=HairdresserRestHandler, handler_method='hairdresser_delete_image', name='HairdresserDeleteImageRestHandler', methods=['DELETE']),

This route calls the hairdresser_delete_image method in the HairdresserRestHandler.

But I have a 405 Method Not Allowed Error message when calling this URL.

I also have others routes which begins with /api/hairdressers/ but with others params and verbs. Does anybody know what am I doing wrong?

1 Answer 1

1

The problem I am guessing is in your python server code.

You handler for deleting images should look like this, note that I am defining a function called delete not get or anything else, this will allow the method to be executed.

class HairdresserDeleteImageRestHandler(webapp2.RequestHandler):
def delete(self):
    self.response.write('I will delete an image!')

On another side note make sure your urls match, I notice deleteimage in your Route path but not in the url you are calling /api/hairdresser/877848/images/5451681

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you for your answer ! I am actually using the handler_method= attribute which allows to redirect the request to a specific function in my handler ! Effectively I had not the same url in my $resource and python code, I correct it but still have the same issue ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.