Closed thegreyd closed 7 years ago
@thegreyd The reason it throws an error is because single quote is not a legal JSON format, you need to use double quotes instead. There's nothing I can do on the server side since there's a strict policy regarding JSON format.
even this doesn't work
curl -k -v -H "Content-Type:application/json" -X POST -d "{"magiclink":{"email":"sid.sharma0@gmail.com"}}" https://zapserver.herokuapp.com/api/magiclinks/
this used to work in the login request.
Here's what I am doing for login request:
json_request = String.format("{ \"session\": { \"email\": \"%s\", \"password\": \"%s\" } }",email, passwd);
Here's the magic link json
json_request = String.format("{ \"magiclink\": { \"email\": \"%s\" } }",email);
Got it. An error in the url.
Cool. I'm making a change to the return JSON since now it returns nothing after sending the magic link email
Done. Now it will return a JSON: {"Message":"Magic Link Sent"} if the email is sent out successfully.
When I make the following call, it returns a bad request:
curl -k -v -H "Content-Type:application/json" -X POST -d "{'magiclink':{'email':'sid.sharma0@gmail.com'}}" https://zapserver.herokuapp.com/api/magiclinks/
{"status":400,"error":"Bad Request"}
Instead when you make this call it accepts
curl -k -v -H "Content-Type:application/json" -X POST -d '{"magiclink":{"email":"sid.sharma0@gmail.com"}}' https://zapserver.herokuapp.com/api/magiclinks/
Response: 204
The difference between them is in the JSON body, I inter-changed single and double quotes. I am not able to implement the single quotes version in Java, because strings can't be inside single quotes. Please fix this.