Click here to Skip to main content
15,354,044 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to learn how to create a json REST webservice and starting off with a simple example ... but can't get it to function. This is what I get when attempting to call it with a cUrl ...

curl -X GET -v http://localhost:8733/Design_Time_Addresses/HelloService/HelloService/GetData/value/334
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying ::1...
* Connected to localhost (::1) port 8733 (#0)
> GET /Design_Time_Addresses/HelloService/HelloService/GetData/value/334 HTTP/1.1
> Host: localhost:8733
> User-Agent: curl/7.55.1
> Accept: */*
< HTTP/1.1 405 Method Not Allowed
< Allow: POST
< Content-Length: 0
< Server: Microsoft-HTTPAPI/2.0
< Date: Mon, 02 Nov 2020 21:20:50 GMT
* Connection #0 to host localhost left intact


If it matters I am running/serving the service using "debug mode" which calls the WCF Test Client application.

Can anyone please tell me why it thinks I should be asking for a POST?

What I have tried:

Here are my HelloService.VB, IHelloService.VB and my App.Config files:

Public Interface IHelloService

    Function GetData(ByVal value As String) As String

End Interface

Public Class HelloService
    Implements IHelloService
    <WebInvoke(ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json, Method:="GET", UriTemplate:="value/{value}")>
    Public Function GetData(ByVal value As String) As String Implements IHelloService.GetData
        Return String.Format("You entered: {0}", value)
    End Function

End Class

<?xml version="1.0" encoding="utf-8"?>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
    <compilation debug="true" />
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      <service name="HelloService.HelloService">
        <endpoint address="web" behaviorConfiguration="JsonBehavior"
          binding="webHttpBinding" contract="HelloService.IHelloService">
            <dns value="localhost" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/HelloService/HelloService/" />
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="False" />
        <behavior name="JsonBehavior">
          <webHttp />

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900