Customer Portal

HTTP POST text file

Comments 5

  • Avatar
    sshrestha
    0
    Comment actions Permalink
    Sorry, the correct link should be http://doc.cloveretl.com/documentation/UserGuide/index.jsp
  • Avatar
    the_goat
    0
    Comment actions Permalink
    Not sure which particular example you're referring to. "Upload a File using Multipart Entities"? I do not believe you need to do that, just choosing input file in this simple case as you outline should be fine.

    My best guess would be, "Content-Length" header is not being sent along in which case you can just add this header with proper information using "additionalHTTPHeaders" from "Input mapping". Try to enable debug logging (Run -> Run configurations) to see which headers are being sent with your message.
  • Avatar
    sshrestha
    0
    Comment actions Permalink
    Thank you for your suggestions. You are absolutely right about the content-length not being sent in the header. I could not quite figure out how to figure out the content length of the file being sent.

    http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.gui.docs/docs/httpconnector.html
    In the link above there is an example of file upload using multipart entities which I could not make it work.

    When you said 'just choosing input file in this simple case as you outline should be fine', which field name should the file to be uploaded attached to? Do you mean 'inputFileUrl'? I thought that field takes a file and constructs HTTP request from that file content.
  • Avatar
    admin
    0
    Comment actions Permalink
    Hi Shubha,

    As a user "the_goat" already advised, the HTTP "411 Length Required" client error response code usually indicates that the server refuses to accept the request without a defined Content-Length header. Generally, the Content-Length header should always be set when a POST is involved, therefore, the CloverETL sends the Content-Length automatically based on the content itself. So usually, you don't need to worry about it. In your case, I believe that the system didn't have any content available for calculating the Content-Length header.

    If your requirement is to simply send a file with the HTTP POST request I don't believe the function Multipart Entities is really necessary. The multipart messages are used in case you have more different sets of data and you want to combine them in s single body of the request. I believe that you can avoid it entirely.

    As you said, the right field to use is the "Input file URL" attribute or "inputfileURL" field within Input Mapping editor.
    In accordance with the examples in the documentation, you would need to set up the following in a HTTPConnector component:
    URL: http://clover:clover@localhost:8080/your/app/path
    Request method: POST
    Input file URL: ${DATAIN_DIR}/some.txt


    Please give this a try and let me know if it works, or please provide me with more details about the HTTP endpoint you are accessing and its requirements.

    Thank you and have a nice day, Eva
  • Avatar
    the_goat
    0
    Comment actions Permalink
    @sshrestha: yes, I absolutely do. Though if you choose to use this option (can provide different URL using Input Mapping property), the drawback would be; you have to have file available somewhere on filesystem.

    In case, you're using some sort of serialization (e.g. using JSONWriter) and you actually are using "requestContent" property from Input Mapping, then you should be able to use httpHeaders or rawHttpHeaders property to provide content length manually, I believe application of function length() on that string should be sufficient method.

    Would you be able to provide graph you already have, so I can take a look and be less "theoretical"?

Please sign in to leave a comment.