HTTP Post and Multipart


I have a pipeline (see below) which attempts to upload PDF files from the file system to a web service using the service's API. The API requires that multipart/form-data POSTs are used.

Currently I get a series of HTTP 500 status responses. As the API isn't very detailed in its responses I don't know if the problem lies in the encoding of the body or how the multipart has been constructed.

I have tried sending the PDFs as content-type="text/plain" and content-type="application/octet-stream" encoding="base64" but both ways get me the same response. If I change to multipart/mixed the it complains bitterly so at least I know I haven't got that part wrong. I'm assuming that something a browser does when it sends multipart/form-data is not what's happening here.

I'm doing something wrong, that's for sure, but what that is I don't know. Does anyone have any ideas?

I'm using the most recent Calabash from within oXygen 12.1 on Windows 7.



<?xml version="1.0" encoding="UTF-8"?>

  <p:output port="result"/>

  <p:serialization port="result" encoding="UTF-8" indent="true"
    media-type="application/xml" method="xml"/>

  <p:import href="../lib/library-1.0.xpl"/>

  <p:directory-list name="content" path="test/resources/assets" include-filter=".*\.pdf"/>

  <p:make-absolute-uris name="directory" match="//c:file/@name">
    <p:with-option name="base-uri" select="/c:directory/@xml:base"/>

    <p:iteration-source select="/c:directory/c:file"/>
    <p:identity name="fileRef"/>

    <p:document-template name="get-request">
      <p:input port="template">
                <c:request method="GET" href="{/c:file/@name}" override-content-type="text/plain"/>
      <p:input port="source"/>
      <p:input port="parameters">

    <p:http-request name="retrieve"/>

    <p:document-template name="post-request">
      <p:input port="source"/>
      <p:input port="template">
          <c:request method="POST"
            <c:multipart content-type="multipart/form-data" boundary="=-=-=-=-=">
      <p:input port="parameters">

    <p:http-request name="create"/>


  <p:wrap-sequence wrapper="c:result"/>

Received on Wednesday, 23 March 2011 20:24:36 UTC