How to send a mimestream using pub.client:http

Hi community!

i have to create and pass a multipart/form-data mimestream through the pub.client:http service.
I am able to produce following mime string.

[i]
Message-ID: 1183093294.126.1520957381494.JavaMail.DEDCW28EAI201$@DEDCW28EAI201
MIME-Version: 1.0
Content-Type: multipart/form-data;
boundary=“----=_Part_125_1965686719.1520957381494”

------=_Part_125_1965686719.1520957381494
Content-Type: application/json

{
“id” : “00d75c67-21d8-43d8-a675-505173a9a170”,
“fields” : {
“DokumentartRgWare” : “GS”,
“Barcode” : “”,
“Lieferscheinnummer” : “”,
“RechnungsNr” : “”,
“Rechnungsdatum” : “06.10.2017”,
“Lieferantenname” : “”
}
}
------=_Part_125_1965686719.1520957381494–
[/i]

This contains the correct Content-Type header which is needed by the application server that is going to deal with the request.

Then i pass this string to the pub.client:http service.

Now the remote service fails with: “Unable to get boundary for multipart”

When i checked the HTTP Trace, i can see that IS is setting the Content-Type to “application/x-www-form-urlencoded”,
which explains the error message. It looks like pub.client:http does not take care of the mimestring headers and passes the complete mimestring (including headers) as body.

What do i have to do, to get
Content-Type: multipart/form-data;
boundary=“----=_Part_125_1965686719.1520957381494”

as a http request header?

Kind regards,
Martin

IS Version: 9.7
mime.txt (594 Bytes)

1 Like

Hi,

Can you please add a very first step with flow:getTransportInfo in the receiving svc logic and see what you get in the pipeline?

Also I assume you have set the Content-Type in the send http service and receiving service the service input set as *Node object or *ContentStream?

HTH,
RMG

Hi RMG,

thank you for your reply. I found the solution myself.

After pub.mime:createMimeData, pub.mime:addBodyPart and pub.mime:getEnvelopeStream you can easily pass the generated envStream to pub.client:http (data/mimeStream).

IS then takes the header of the stream and appends them to http headers.

I changed my implementation accordingly and it is working fine.

Kind regards,
Martin

I also assume you have set this in the http service param:

Content-Type: multipart/form-data

I think you are indeed good on track:)

Cheers!
RMG

Hello,
I have the same need for my project but I don’t success

can you share your code ?

remarks : whereas in others “languages” like Java or C, we can’t share easily source code of flow service. I don’t see anywhere in w3 some code.
what is the good way to share ?

thanks

Hi Bruno,

please check the attachment. There is a steb by step documentation what i did to get it working.

It´s important that you do not operate on the envStream object, that is generated by pb.mime:getEnvelopeStream before passing it to pub.client:http. Otherwise the stream is empty.

Hope it is working.

Kind regards,
Martin

StepByStep.pdf (118 KB)

1 Like

Hi Martin, This is too late to ask this, but if you remember, please let me know if passed any input to pub.mime:createMimeData. Because same implementation is not working for me in the pub.mime:getEnvelopeStream step.

thanks for your help

client:http was sending application/x-www-form-urlencoded because :
I was using pub.io.streamToString with envStream from getEnvelopeStream for debug before launching client:http

Strange no ?

Hi Bruno,

Do you still need help on this or code is in working condition now?

HTH,
RMG