Menu

HTTP Requests

Anonymous
2024-01-27
2024-01-27
  • Anonymous

    Anonymous - 2024-01-27

    How could i go about making post and get HTTP requests through GnuCOBOL? I havent found any gppd resources online to do this so I've turned to the forums

     
    • Mickey White

      Mickey White - 2024-01-27

      You will get better and most likely quicker response if you login to the forum.
      Here is an example I use on linux to get a random number from the random number generator web site.

              IDENTIFICATION DIVISION.
              PROGRAM-ID. wgetwwwrandomorg.
              environment division.
              configuration section.
              source-computer.
                  Summit
            *           with debugging mode
                  .
      
             input-output section.
             file-control.
                 select  i-foo  assign "foo"
                     organization is line sequential.
             data division.
             file section.
             fd i-foo.
             01 i-foo-rec.
                88 i-foo-eof  value  high-values.
                05 i-foo-num                                    pic 9(09).
      
              WORKING-STORAGE SECTION.
             01 one pic x(80)
                 value " wget -O foo 'https://www.random.org/integers/".
            *    value " wget 'https://www.random.org/integers/".
             01 two pic x(80)
                 value "?num=1&min=1&max=999999999&col=9&base=10".
             01 three pic x(80)
                 value "&format=plain&rnd=new'".
             01 callparm pic x(3200).
      
              PROCEDURE DIVISION.
                 move function concatenate(
                      function trim(one),
                      function trim(two),
                      function trim(three),space)
                   to callparm
                 call "SYSTEM" using callparm
                 end-call
                 open input i-foo
                 read i-foo
                         at end move high-values to i-foo-rec
                 end-read
                 if  i-foo-eof
                     display "foo empty" upon syserr
                     move -1 to return-code
                     stop run
                 end-if
                 display "foo num = " i-foo-num
                 close i-foo
            *    call "CBL_DELETE_FILE" using "foo"
            *    end-call
                 goback.
      
       
      • Simon Sobisch

        Simon Sobisch - 2024-01-27

        Using an external command (often would be curl or even Powershell) if one option.

        @ Mickey: can you please check for other options presented in the contrib area and provide a second version using these?

         
        • Mickey White

          Mickey White - 2024-01-27

          I will look into it...

           

Anonymous
Anonymous

Add attachments
Cancel