Reputation: 959
Problem Question:
I am making a post call to my API but keep on getting 500 server error. After doing some debugging API is expecting data in different format
API excepting --
user[email] -- json would be {user =>{email=>'[email protected]'}
I am sending as
return $http.post(urlBase + '/users/password',{email: email});
json is like {"user":"[email protected]"}
Recently started learning. So please guide me or provide me with any resources.
Upvotes: 0
Views: 1269
Reputation: 21901
try this one,
$http({
method: 'POST',
url: urlBase + '/users/password',
data: $.param({email: email})
});
OR
$http({
method: "POST",
url: urlBase + '/users/password',
params: {email: email}
);
Upvotes: 0
Reputation: 6298
Try to send this:
{"user": {"email":"test@test"}}
This is similar to:
user.email = "test@test";
In your case:
return $http.post(urlBase + '/users/password',{user:{email: email}});
This is a good reference for this: JSON Syntax
Upvotes: 1