z/OS Tools & Language

Expand all | Collapse all

curl payload conversion

  • 1.  curl payload conversion

    Posted 10-30-2020 15:19
    I am able to call a REST service with an MVS data set using the standard z/OS "//" style, as follows:
    curl -H "Content-Type: application/xml" -X PUT -d @"//'DVFJS.TC.TXT'" https://{hostname}/communication/rest/templateCommunication/{resourceID}

    However the MVS data set has to already be in the appropriate codepage (ASCII or whatever).  Is there anything I can do at the curl level to indicate that the source file is in EBCDIC and should first be converted to another codepage?

    ------------------------------
    Frank Swarbrick
    FirstBank
    ------------------------------


  • 2.  RE: curl payload conversion

    Posted 11-02-2020 06:03
    Hi Frank Swarbrick,
    You can try the following:
    curl -H "Content-Type: application/xml" -X PUT -d  `cat "//'DVFJS.TC.TXT'"`
    Thanks,
    Alex

    ------------------------------
    Alexander Klochkov
    Rocket Software
    ------------------------------



  • 3.  RE: curl payload conversion

    Posted 11-03-2020 13:42
    Thanks Alexander.  I'm not too Unix savvy so I never would have figured this out.
    For what its worth, I also got this working with a "form" upload.
    Note, I also decided to use $() instead of back quotes. 

    //CURLTEST JOB NOTIFY=&SYSUID
    //UNIX EXEC PGM=BPXBATCH
    //STDOUT DD SYSOUT=*
    //STDERR DD SYSOUT=*
    //STDPARM DD *
    SH curl
    --trace-ascii /dev/stderr
    --silent
    --header "X-Atlassian-Token: nocheck"
    --form "file= <this is a test>: tst2.txt;filename=tst1.txt"
    --form "file=$(cat "//'DVFJS.TEST.TXT'");filename=tst2.txt"
    --form "file= $(cat "//'DVFJS.TCE.TXT'");filename=tst3.txt"
    https://jira.fb/rest/api/2/issue/CCOE-54/attachments
    /*


    Note that I put a space after "file=".  This seems to be required if the first character in the file is '<'.  I assume the shell was interpreting that as a redirection, or some such thing.

    Thanks for you help!

    ------------------------------
    Frank Swarbrick
    FirstBank
    ------------------------------