Resolved How to Post to a REST Service


Well-known member
May 11, 2010
Auckland, New Zealand
Programming Experience
Program JSPG2 is a COBOL program providing a REST (.json) web service that was generated by MANASYS Jazz, and compiled into a mainframe environment as a CICS web service. I have successfully tested it with SOAPUI. Now I want to develop client-side logic to invoke this service: I want to enhance MANASYS Jazz so that when it generates a program like JSPG2 it also creates corresponding interface objects (VB.Net, C#, Java) to encapsulate all the interface rules, so that client-side logic can simply refer to the interface object's properties and methods. This will make it very easy for the client-side developer to access the service, and the generated logic will guarantee that client-side input validation is consistent with server-side validation.

However my immediate objective is to create just one VB.Net program to invoke program JSPG2 so that I have a pattern to work from.

I Googled "Post to Web Service" which found this - Set up POST REST Service - that looked exactly what I wanted, but when I tried their example I couldn't get it to compile: because of Message BC30002 for 'ApiController' and 'FromBody'
Imports System.Net
Imports System.Web.Http
Public Class JSPG2Controller
    Inherits ApiController
Message BC30002 Type 'ApiController' is not defined
ApiController is defined in System.Web.http so it should have been be OK, but the documentation hints that ApiController has been replaced.

Perhaps this is the wrong approach? What is the best tutorial for me to I read? Preferably VB, but C# is also OK.
Not sure exactly, but I think you need to install package Microsoft.AspNet.WebApi.Client with Nuget manager.
Not sure exactly, but I think you need to install package Microsoft.AspNet.WebApi.Client with Nuget manager.
Thanks for this suggestion JohnH. First I'm going to to the upgrade to VS 2019 that you recommended with my previous query (I'm doing it now), then if that doesn't solve the problem on its own I'll come back to this.
This looks really useful - it's the first thing I've seen from Microsoft that mentions Swagger. When MANASYS Jazz generated program JSPG2, as well as the COBOL it generated a Swagger definition of the service, referencing the .json schemas for the input and output messages. So this looks a more productive approach than using APIController that I tried first, or NewtonSoft.json that was downloaded from Microsoft.AspNet.WebApi.Client. So I will check this out.

There is a problem however: this requires Net.Core, whereas I've been using .Net Framework (now upgraded to 4.7.2). I'm setting up a new project for this test, using VS 2019 and Net Core 3.1.2 It looks as if I can only use VB with Net Framework, not Net Core. Is this correct? If this is true, then I'll have to work with C#. (I'll do this if I have to, it is not a fatal problem).
I just migrated all of my Web API's to .NET Core and EF Core - wonderful work by Microsoft. If you want to use .NET Framework you can use the ASP.NET Web API for that:

Thanks Sheepings, that makes it clear. I'll change my objectives: interface objects will be generated for C# only. Should I end up with a client that has a VB.Net project that they want to connect to the web services that MANASYS Jazz has created, they can add a C# project to their solution to host the interface: there is no rule that says that all the projects in a solution have to use the same language.