Score:-1

"No route found for GET" on custom REST resource when posting

cn flag

I'm seeing really weird behavior. I've created a custom REST resource at the route /user/login-special.

This is a passwordless login resource, so I pass the mail address and then get a response that says Login email was sent!

However, when I POST to the https://abc-xyz-123.us-3.platformsh.site/user/login-special?_format=json, I get the error:

{
    "message": "No route found for \"GET https://www.abc-xyz-123.us-3.platformsh.site/user/login-special?_format=json\" (from \"https://abc-xyz-123.us-3.platformsh.site/user/login-special?_format=json\")"
}

The route definitely exists... what is going on? And why is it saying GET when I used POST?

Score:1
cn flag

Read the error carefully.

You POSTed to https://abc-xyz-123.us-3.platformsh.site/user/login-special?_format=json, but it is returning https://www-- you're getting redirected.

So the solution is to POST to https://www.abc-xyz-123.us-3.platformsh.site/user/login-special?_format=json and everything works as expected.

This might be obvious to most people, but I wasted a lot of time debugging this today, so I'm posting it here in case anyone else makes the same mistake in the future.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.