Request: Visual Cobol Program w/ web API on a Visual Studio platform


Are there samples of Visual Cobol program that access web API? 

We don't have Eclipse and work on a Visual Studio platform.  

  • Not sure if this is exactly what you were looking for but here is an example of accessing a web service using our .NET COBOL syntax:

    class-id ManagedCOBOL.LocalTimeHelper.

    *>> <summary>
    *>> This method returns the local time for a store
    *>> </summary>
    *>> <param name="latitude">I'll give you 1 guess as to what this needs...</param>
    *>> <param name="longitude">Oh come on</param>
    *>> <returns>The local time in a given latitude/longitude according to Google</returns>
    method-id GetLocalTime static.

    procedure division using by value latitude as float-long, by value longitude as float-long,
    returning res as string.

    declare client = new type RestSharp.RestClient("")
    declare request = new RestSharp.RestRequest("timezoneJSON", type RestSharp.Method::GET)

    invoke request::AddParameter("lat", latitude)
    invoke request::AddParameter("lng", longitude)
    invoke request::AddParameter("username", "microfocals")

    declare response = client::Execute[type GeoNamesTimeZone](request)

    set res to response::Data::time

    end method.

    end class.

    class-id GeoNamesTimeZone.
    working-storage section.
    01 sunrise string property.
    01 lng string property.
    01 countryCode string property.
    01 gmtOffset string property.
    01 rawOffset string property.
    01 sunset string property.
    01 timezoneId string property.
    01 dstOffset string property.
    01 countryName string property.
    01 time string property.
    01 lat string property.
    end class.

    *Example JSON reply for the timezoneJSON API:
    * "sunrise": "2019-05-17 05:41",
    * "lng": 10.2,
    * "countryCode": "AT",
    * "gmtOffset": 1,
    * "rawOffset": 1,
    * "sunset": "2019-05-17 20:49",
    * "timezoneId": "Europe/Vienna",
    * "dstOffset": 2,
    * "countryName": "Austria",
    * "time": "2019-05-17 14:01",
    * "lat": 47.01