0

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=>'test@test.com'}

I am sending as

return $http.post(urlBase + '/users/password',{email: email});
json is like {"user":"test@test.com"}

Recently started learning. So please guide me or provide me with any resources.

GeekOnGadgets
  • 941
  • 3
  • 14
  • 47

2 Answers2

1

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

Denis C de Azevedo
  • 6,276
  • 2
  • 32
  • 49
0

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}                         
);
Kalhan.Toress
  • 21,683
  • 8
  • 68
  • 92