Page 1 of 1

Posting to external web api

Posted: Thu Mar 13, 2014 2:59 pm
by Jason Carmen

Hello when trying to post to my web api I get no values passed out when using the Create new Rest Service

Here is the post value:
{"ID":,"Username":"jason","Password":"jason","UserDetailID":1,"DateOfBirth":"1971-11-09T00:00:00","Email":"a href="mailto:jason@jason.com" rel="nofollow"jason@jason.com/a"}

And the URL i am trying to post to is : http://www.fangatez.com/api/User

Here is me trying to do this in JQuery:

I tried it with array brackets and without.

Here is my api Post Method call:
public User Post([FromBody]User user)
{
using (FangateEntities context = new FangateEntities())
{
User u = new User();
u.Username = user.Username;
u.Password = user.Password;
u.Email = user.Email;
u.DateOfBirth = user.DateOfBirth;
u.UserDetailID = user.UserDetailID;
context.Users.Add(u);
context.SaveChanges();
return u;
}
}

Am I doing something wrong? It posts but with no data the User object is null when it gets to my Method.


Posting to external web api

Posted: Thu Mar 13, 2014 3:27 pm
by Nikita

Hello,

Why don't you use a rest service?
http://docs.appery.io/documentation/r...


Posting to external web api

Posted: Thu Mar 13, 2014 3:48 pm
by Jason Carmen

lol I am that is what I am telling you. Also did you notice how your tutorial does not explain Post it only describes Get.

Can you tell me how you would set up this using your rest service OOB functionality?

And the URL i am trying to post to is : http://www.fangatez.com/api/User

You can also use the Get to see the fields if you need to. But just in case you don't want to do that here is a screen shot:

Image


Posting to external web api

Posted: Thu Mar 13, 2014 4:23 pm
by Nikita

Hi,

If you want to send this data, then you should add it in tab Request instead Response.


Posting to external web api

Posted: Thu Mar 13, 2014 5:26 pm
by Jason Carmen

So what I found out is that since the API url is already handling the object "User" there is no need to build an array. You just need to create thew values for the request as you do with a get rather then build the object array.

thanks for your help.


Posting to external web api

Posted: Thu Mar 13, 2014 7:19 pm
by Nikita

Hi,

Did you get it working?


Posting to external web api

Posted: Mon Apr 21, 2014 9:49 am
by Abu Ali

Hi,
i have the same issue, what was the final solution ?
thanks


Posting to external web api

Posted: Tue Apr 22, 2014 1:33 am
by Illya Stepanov

Hi Ali,

Please clarify your problem. We need more details like screenshots and describe what you want to do and what is not working as expected.

We will help you after.

Thanks & Regards.