Accept the postbody from a POST-Request

Hello Everybody,

I try to accept the postbody from a POST-Request in a cobol program.

With a GET-Request everthing works fine (with "field a pic x(5) identified by fielda"). I get all the expected data.

But problems occur with the POST-Request .

I tried Chris Glaziers Cobol-Example (LInk:  Calling COBOL program using AJAX with POSTed data  )
In the mentioned buffer I got only NUL-Data.

Chris Glaziers Example show the accept to values from the environment. This works great.

My Postbody is a normal Json-structure with the length of 212 Bytes.

After execution of the Post-Request the received content-Length  for example shows 212 Bytes. The accept-buffer for the POSTBODY contains 212 NUL-Bytes.

I am really confused. 

I warmyl welcome a solution for this problem. 

Thank you

Roland Stein



  • Hi Roland,

    My example that you reference is 10 years old.
    Are you trying to run this program as is or have you modified it for your own requirements? If you modified it can you please show me what it contains?

    What version of Net Express/Server Express  are you using?
    Under which Web Server are you running and on what environment?
    How are you sending the POST request?

    Thanks

    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

  • Hi Chris,
    thank you for your response to my question.
    Let me explain the problem in detail:
    My first POST-Request looks like:
    http://{{domain}}/cgibin/cg3mqconsumer
    with a postbody like
    {"uuid":"36746d21-8e85-4601-9dc9-7d261946045c","topic":"standard","table":"xy","key":"39303030303430303930303030303939","field":"","value":"2039303030303430303930303030303939546573746B756E6465204469636F6E2020202020202020202020202020202020202020202020202054657374322020202020202020202020202020202020202020202020202020202020202020202020546573743320202020202020202020202020202020202020202020202020202020202020202020205465737473747261737365203120202020202020202020202020202020202020202020202020202020202037393130302020202020202020202054657374737461647420202020202020202020202020202020202020202020202020202020202020506F737466616368202020202020202020202020313937303020202020202020202020202020202020202020202020202020746573746B756E6465206B6C6D2020202020202020202020202020202020202020202020202020202020202020303230312F313730342D313237202020202020202020202020202020202020202020202020202020202020202020202020203032303131373034313434202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020206564764062756D6B652E64652020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020206A3236303632303032303030303030303020202020202020202020202020202020202020207773207565622020202020202020202020202020202020323730363230323330393531343037386677202020202020202020202020202020202020667720443353444B4431312020202020202020202020203030303031353331","date":20230711121126930}
    This is a JSON-Message which i have to work with in my cobol-program.
    But, this JSON was not grabable in STDIN. The standard-input has no data.
    I tried your solution within my program - but it doesnt work.
    I do have problems to call "A7". The program crashes.
    Meanwhile, i resolved it with this construction, i think it's a workaround:
    http://{{domain}}/cgibin/cg3mqconsumer
     
    with this postbody
     
    message={"uuid":"36746d21-8e85-4601-9dc9-7d261946045c","topic":"standard","table":"xy","key":"39303030303430303930303030303939","field":"","value":"2039303030303430303930303030303939546573746B756E6465204469636F6E2020202020202020202020202020202020202020202020202054657374322020202020202020202020202020202020202020202020202020202020202020202020546573743320202020202020202020202020202020202020202020202020202020202020202020205465737473747261737365203120202020202020202020202020202020202020202020202020202020202037393130302022020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020206A3236303632303032303030303030303020202020202020202020202020202020202020207773207565622020202020202020202020202020202020323730363230323330393531343037386677202020202020202020202020202020202020667720443353444B4431312020202020202020202020203030303031353331","date":20230711121126930}
    Keep a eye to the little word "message=" at the beginnig of the message.
    This allows to get the message in the programm with this declaration:
    01 MQForm is external-form.
        02 MQControls.
              03 mq-message PIC X(99999)   IDENTIFIED "message".
    INITIALIZE MQForm.
    ACCEPT MQForm.
    First, you see my working-storage declaration, and at second the code to get the postbody.
    We use this technique often when dealing with GET-requests.
    But now we must use the POST-Request because the JSON-Data is too long for GET.
    I'm so sorry, but i can't give you my code containing your code, because i deleted it after implementing the workaround.
    If you have any ideas, question or so, pls contact me.
    Best regards
    Roland Stein