Your question has been submitted and is awaiting moderation.
Thank you for reporting this content, moderators have been notified of your submission.
Hi,
I am a Dotnet developer and am new to Creating web API.
The following code is the example which prints"Hello World!"
RouteMapClass.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetNuke.Web.Api;
namespace My.WebAPI
{
public class RouteMapClass
{
}
public class RouteMapper : IServiceRouteMapper
{
public void RegisterRoutes(IMapRoute mapRouteManager)
{
mapRouteManager.MapHttpRoute("TAC_Venkata", "default", "{controller}/{action}", new[] { "My.WebAPI" });
}
}
}
MyController.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
namespace My.WebAPI
{
public class MyController: DnnApiController
{
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage HelloWorld()
{
return Request.CreateResponse(HttpStatusCode.OK, "Hello World!");
}
}
}
Copy and Paste following URL in Browser: -
~/DesktopModules/MyFolder/API/SampleEduPoint/HelloWorld
And i wrote my code as follows:
CreatePotentialStudentController.cs:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
namespace My.Modules.Entities.Manage
{
public class CreatePotentialStudentController: DnnApiController
{
public string str = "";
public void CreatePotentialStudent(string Title, string FirstName, string FamilyName)
{
ServiceReference1.CreatePotentialStudentInput obj1= new ServiceReference1.CreatePotentialStudentInput();
obj1.Title = Title;
obj1.FirstGivenName = FirstName;
obj1.FamilyName = FamilyName;
ServiceReference1.CreatePotentialStudentServiceClient obj2 = new ServiceReference1.CreatePotentialStudentServiceClient();
obj2.CreatePotentialStudent(objCreatePotentialStudentInput);
ServiceReference1.CreatePotentialStudentOutput g = new ServiceReference1.CreatePotentialStudentOutput();
//return g.ReferenceNo;
//return Request.CreateResponse(HttpStatusCode.OK, g.ReferenceNo);
str = g.ReferenceNo;
}
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage CreatePotentialStudent()
{
return Request.CreateResponse(HttpStatusCode.OK, str);
}
}
}
I want to modify my code as per the Hello world example which i gave above. And return student reference number using this API .
Can you please check this and give me reply.
Thanks,
Venkata