Created a REST service with WebAPi, but now how to consume it?

Topics: Web Api
Jul 19, 2011 at 3:13 PM

Hi there,

 

Can anyone help? 

 

I am finding the documentation a little on the thin side, i have created the WebApi (basically a MVC app ) by following a tutorial here.... works great and pretty much understand that.

 

But how do we consume these with the new APIS?

 

Does anyone have tutorials ?  What methods to use? What namespace?

 

I saw this -   "HTTP - Discussions about the new enhancements to WCF HTTP"   but it seems to be dead ???

 

I don't want to use The Preview Starter kit as this is supposed to replace that, i presume also for the client.

 

Thanks in advance for any help.

Coordinator
Jul 19, 2011 at 3:28 PM

You can basically consume a web api from any http client.

It depends on what kind of client you are using to consume it. If you are doing a mashup / consuming from a .net client you can use our new HttpClient api. If you look in our samples at the QueryableSample (in the drop) you see how to do this.

If you are wanting to consume from a browser then you will either use raw javascript / xmlhttprequest or if you are using something like jQuery you can use $getJson. If you look at either our JsonValue or ContactManager sample you will see how to do this.

Jul 19, 2011 at 3:42 PM

Thanks Glenn!

 

The HTTPCLient api is part of the WebApi (new api ?)?   

 

This has the method, ReadAsDataContract so its possible to import JSON directly into a .net class?

 

Thanks once again

Jul 19, 2011 at 4:21 PM
It's a nuget. http://kzu.to/nEPgtf

/kzu

--
Daniel Cazzulino | Developer Lead | MS MVP | Clarius Consulting | +1 425.329.3471


On Tue, Jul 19, 2011 at 12:42, madridjohn <notifications@codeplex.com> wrote:

From: madridjohn

Thanks Glenn!

The HTTPCLient api is part of the WebApi (new api ?)?

This has the method, ReadAsDataContract so its possible to import JSON directly into a .net class?

Thanks once again

Read the full discussion online.

To add a post to this discussion, reply to this email (wcf@discussions.codeplex.com)

To start a new discussion for this project, email wcf@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jul 19, 2011 at 4:25 PM

Thanks!

Coordinator
Jul 19, 2011 at 4:29 PM

It's included as part of our webapi.all nuget, but as Daniel implemented there is an HttpClient nuget if you JUST want the client. I'd recommend getting webapi.core though as it contains support for formatters / serialization as HttpClient contains minimal support itself.

Glenn

Jul 20, 2011 at 7:14 AM

Thanks, just the confirm i was hoping for...

 

Thanks again!