1

I have a WCF application with SOAP and RESTful end points which I followed from this tutorial.

everything was working great I could call basicHttpbinding data. Now I am trying to call data from the RESTful side, I received this error when coding the

Error 1 'System.ServiceModel.Web.WebGetAttribute' does not contain a definition for 'Method'

the error is shown here:

[OperationContract]
    [WebGet(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "getTrucksA")]
    List<RTrucks> GetTrucksA();

I did check out this question on Stack Overflow and tried all answers like

  • Removing using System.ServiceModel.Web and adding it again.

  • Adding Reference

  • changing the Framework target in my project settings

    but nothing works.

any ideas?

Community
  • 1
  • 1

2 Answers2

1

The WebGetAttribute does not have a property named Method. There is no need to set the method as WebGet always refers to a GET request. So remove the part Method = "Get", and you are good to go.

Markus
  • 16,725
  • 3
  • 27
  • 49
0

WebGet as defined by MS does not require the Method = 'Get' as you posted because WebGet is for the verb GET, you can use WebInvoke(Method='POST') for POST.

wjvander
  • 571
  • 5
  • 15