How to sent a POST request with form-data and parameters in PL/SQL

后端 未结 2 1142
滥情空心
滥情空心 2020-12-21 12:13

I\'m trying to call REST WebService in PL/SQL but it doesn\'t work. I get this error:

Content-type must be multipart/form-data

相关标签:
2条回答
  • 2020-12-21 12:49

    I don't think you can use a POST with GET query like you do in the URL...

    It looks quite difficult to do what you expect. Here is some input from Ask Tom:

    The idea is to generate the post text, including a specific "boundary", which will look like this:

    POST /path/to/script.php HTTP/1.0
    Host: example.com
    Content-type: multipart/form-data, boundary=AaB03x
    Content-Length: $requestlen
    
    --AaB03x
    content-disposition: form-data; name="field1"
    
    $field1
    --AaB03x
    content-disposition: form-data; name="field2"
    
    $field2
    --AaB03x
    content-disposition: form-data; name="userfile"; filename="$filename"
    Content-Type: $mimetype
    Content-Transfer-Encoding: binary
    
    $binarydata
    --AaB03x--
    

    There is also same issue developed here with lots of code.

    Hope it helps.

    0 讨论(0)
  • 2020-12-21 13:01

    I use a similar procedure with POST method at the http request, however I'd set header like:

    UTL_HTTP.set_header( v_http_request, 
                         'Content-Type', 
                         'application/x-www-form-urlencoded;charset=utf-8' );
    

    Be aware also that, if the web-service site implements a security certificate, your DBA must create a wallet server-side, and before opening the request you should invoke that wallet:

    utl_http.set_wallet('file:<your wallet file route>', '<your pass>');
    

    More on Wallets can be found here

    0 讨论(0)
提交回复
热议问题