Calling a REST API via POST - how to pass in parameters in JSON

I need to call an API written in C# in out Micro Focus COBOL application.  I found this post very helpful

 RE: Tutorial or example for calling a URL and processing the response 

one thing though

the call needs to ba a POST with input in JSON

I can string together the body - but what is the syntax to attach it to the request?

  • 0  

    What version of the product are you using? Visual COBOL? Which version? Also are using managed code or Native code?

  • 0 in reply to   

    version 8.0

    managed vs native code?  not sure of the difference

  • 0   in reply to 

    Are you using Visual COBOL for Visual Studio or Eclipse?

    Native code refers to programs that are generated as standard Windows .EXE's or .DLLs (or as Micro Focus .INT or .GNT)

    Managed code refers to programs that are generated as .NET assemblies (or Java byte code) and have OO syntax extensions allowing interaction with the .NET Framework (or Java). An example of managed code for .NET is the program example in the link you provided.

    You can dictate the type of code generated by choosing the corresponding project template when creating a new project.  

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to   

    We use Micro Focus COBOL in Visual Studio.  We use 2017, 2019 and 2022 - but I usually use 2017 to look at code.  The application consists of hundreds of dll's, including ESODBCXA and three user exits. 

  • Verified Answer

    +1   in reply to 

    Since you mention ESODBCXA and user exits I am assuming that you are actually using the Enterprise Developer product and running your migrated mainframe application under Enterprise Server and are not actually using the Visual COBOL product? There is a different community forum for Enterprise Developer related questions but we might be able to help you here.

    The example in the link that you provided is written using managed code that interfaces with the .NET Framework. It sounds as if you are running native code .dlls in an Enterprise Server environment so that example would not apply.

    There is a tool called the Interface Mapper Toolkit (IMTK) that will allow you to host a COBOL application as a REST web service but it can also generate a native COBOL client program from a 3rd party WSDL, JSON or OpenAPI  schema.
    It is documented here

    This will generate program sources for both a client and a proxy program. You can replace the client piece with your own client and call the proxy program directly in order to call the web service.

    I would recommend that you post the question in the Enterprise Developer product forum also as you may get a more detailed answer or alternative solution. The forum can be found under Enterprise Suite.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to   

    yes, the code is managed and built with Enterprise Developer and the application run on various servers, development, test and production with Enterprise Server

    will take a look at both links