Jason Carmen
Posts: 0
Joined: Wed Mar 05, 2014 1:51 pm

Posting to external web api

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.

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Posting to external web api

Hello,

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

Jason Carmen
Posts: 0
Joined: Wed Mar 05, 2014 1:51 pm

Posting to external web api

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

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Posting to external web api

Hi,

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

Jason Carmen
Posts: 0
Joined: Wed Mar 05, 2014 1:51 pm

Posting to external web api

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.

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Posting to external web api

Hi,

Did you get it working?

Abu Ali
Posts: 0
Joined: Mon Apr 07, 2014 8:50 am

Posting to external web api

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Posting to external web api

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.

Return to “Issues”