Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am new to REST full Api, i want to create GET method to pass one or two parameters, and return value as json format. Need to create in VB or C#.

What I have tried:

I try to create in C#, but url without function name, i call controller and pass parameter, but i want to call with function and pass parameter.

Below that controller code which i used

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace WebApi2.Controller
{
    public class HelloController : ApiController
    {
        public string Get(int id)
        {

            if (id == 1)
            {
                return "Hello";

            }

            else {
                return "Hello World";
            }
           
        }
    }
}


And url is https://localhost:44300/api/hello/id=1

And i tested with PostMan Agent , it works, but if i call that rest api with my code using Chilkat i will get error. Is it deploy in server ? using localhost will not work ?

Regards
AravindB
Posted
Updated 28-Jan-21 20:39pm
Comments
F-ES Sitecore 29-Jan-21 3:15am    
What's the error you get?

1 solution

 
Share this answer
 

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