InvalidParameterValue: Duplicate header 'Content-Type' when send RawMessage with Amazon SES - email

I'm trying to send a raw email message with Amazon SES API to include attachment.
SES reponse with 400 status code and I not sure what I'm doing wrong, here is the response:
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>InvalidParameterValue</Code>
<Message>Duplicate header 'Content-Type'.</Message>
</Error>
<RequestId>ad8cb17c-a8a0-11e4-8898-8924aa87abfa</RequestId>
</ErrorResponse>
The request signed and work OK with other request, so I think it must only my email message issue. Here is my message data:
Cc: my-verified-email-1#gmail.com
Subject: Hello testing email hahahahaha
Mime-Version: 1.0
Date: 30 Jan 15 23:54 +0700
Content-Type: multipart/mixed; boundary=7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
From: my-verified-email-2#gmail.com
To: my-verified-email-3#gmail.com
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hello <b>testing email</b> with some =E4=B8=96=E7=95=8C and Vi=E1=BB=87t ng=
=E1=BB=AF.
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: text/plain; charset=utf-8; name="test1.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test1.txt"
dGVzdGluZyBzdHJpbmcgd2l0aCBWaeG7h3Qgbmfhu68K
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887--

OK, I just figure out that I was missing a new line before the first boundary line. The message should instead be:
Cc: my-verified-email-1#gmail.com
Subject: Hello testing email hahahahaha
Mime-Version: 1.0
Date: 30 Jan 15 23:54 +0700
Content-Type: multipart/mixed; boundary=7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
From: my-verified-email-2#gmail.com
To: my-verified-email-3#gmail.com
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hello <b>testing email</b> with some =E4=B8=96=E7=95=8C and Vi=E1=BB=87t ng=
=E1=BB=AF.
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: text/plain; charset=utf-8; name="test1.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test1.txt"
dGVzdGluZyBzdHJpbmcgd2l0aCBWaeG7h3Qgbmfhu68K
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887--

Related

How can I forward an email that contains a picture with smtplib?

My code only extracts text types in an email, and forwards the email.
My code:
msg=email.message_from_string(raw_email.decode('utf-8')) #raw_email = fetched[0][1]
content = ''
content_type = None
if msg.is_multipart():
for part in msg.walk():
if part.get_content_maintype() == 'text':
thispart = part.get_payload(decode=True)
if isinstance(thispart, bytes):
thispart = thispart.decode()
content = thispart
content_type = part.get_content_subtype()
else:
if msg.get_content_maintype() == 'text':
thispart = msg.get_payload()
if isinstance(thispart, bytes):
thispart = thispart.decode()
content = thispart
content_type = msg.get_content_subtype()
my_mail = email.message.EmailMessage()
my_mail.set_content(content)
But some emails contain pictures, so what I want more is to forward pictures also.
It comes like this:
Received: from [127.0.0.1] ()
by xxxx () with ESMTP id xxxx
for <xxx#xxx>; Wed, 27 May 2020 18:09:34 +0900
Content-Type: multipart/alternative;
boundary="--_NmP-ebdbfeeb1622aae7-Part_1"
X-FireEye: Clean
From: xxxx#xxxx
To: xxx#xxx
Subject: =?UTF-8?Q?XXXXX?=
Message-ID: <XXXXXX#XXX>
Date: Wed, 27 May 2020 09:09:34 +0000
MIME-Version: 1.0
----_NmP-ebdbfeeb1622aae7-Part_1
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
CONTENT Link </a><br>URL : <a =href></a><br><br><br>
----_NmP-ebdbfeeb1622aae7-Part_1
Content-Type: multipart/related; type="text/html";
boundary="--_NmP-ebdbfeeb1622aae7-Part_3"
----_NmP-ebdbfeeb1622aae7-Part_3
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
CONTENT Link </a><br>URL : <a =href></a><br><br><br> <img src=3D"cid:unique"/>
----_NmP-ebdbfeeb1622aae7-Part_3
Content-Type: image/png; name=image.png
Content-ID: <unique>
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=image.png
LOTS_OF_WIERD_CHARACTERS
----_NmP-ebdbfeeb1622aae7-Part_3--
----_NmP-ebdbfeeb1622aae7-Part_1--
This mail is multiparted, and there are lots of weird characters which seem to represent an image.
How can I create a multipart email that contains an image, and how can I represent that image with the received weird characters??
Thanks:)

Outlook not rendering emails sent

I'm a bit baffled by this. It works fine in everything I've tested, except Outlook
my #all_parts;
push #all_parts, Email::MIME->create(
body_str => $text,
attributes => {
encoding => 'quoted-printable',
content_type => "text/plain",
disposition => "inline",
charset => "UTF-8"
}
);
my $email = Email::MIME->create(
header_str => [
From => $from,
To => [ $to ],
Subject => $subject
],
parts => \#all_parts,
attributes => {
content_type => "multipart/mixed"
}
);
print "Content-type: text/html \n\n";
print "<pre>" . $email->as_string . "</pre> ";
Which outputs this message:
From: delicia#x.com
To: andy.newby#hotmail.com
Subject: webform delicia Menu
Date: Sat, 21 Mar 2020 04:22:57 -0700
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="15847897770.621258BEF.22006"
Content-Transfer-Encoding: 7bit
--15847897770.621258BEF.22006
Date: Sat, 21 Mar 2020 04:22:57 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
foo bar=
--15847897770.621258BEF.22006--
For some reason it shows up buggered:
I must be missing something really stupid - but I can't see it. Maybe a missing header?
The full source of an incoming email looks like:
Return-path: <x#x.com>
Envelope-to: support#mysite.co.uk
Delivery-date: Sat, 21 Mar 2020 15:33:16 +0000
Received: from gt-van-cus5.nmsrv.com ([208.70.247.69])
by admin.foo.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.86_2)
(envelope-from <x#x.com>)
id 1jFg7e-0006lZ-G5
for support#mysite.co.uk; Sat, 21 Mar 2020 15:33:16 +0000
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=x.com; h=message-id
:from:to:subject:date:mime-version:content-type
:content-transfer-encoding; s=mail; bh=TUrwl9pmlEV+CwP8vMMqxIQa9
Bg=; b=G2DuFVkwBF8qkCi7zM3hnwl18nkdIW83JbAoheLTAG9Xh6Ix2bxdPVsP7
3wI1cjUDjWGhTUlMLHGKP5kHT4FPKFkhMclIv+KZ1jU65BaMjRuwWz/FkTRg7v6I
oClvU/PXXn5gqfRiYZHR4L8qgCQaGhuXncxNgtaELqoQosU+gc=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=x.com; h=message-id
:from:to:subject:date:mime-version:content-type
:content-transfer-encoding; q=dns; s=mail; b=VHNvnP4AnMZxow+CoUj
3Xxj5KkIWJtUOJf21kf+E/vhvKWbbb7IEWHFNuQGATCAG+WX529rMQ83l9KsDB9d
G9gRo0Hsw7CK2D56wv7m22ur6QeaCgZNF7xHEECxZkaT9jlI9JFLU8pSXaFvSEcC
YgqKlm2b+zs0Q4mW8mH89xiQ=
Received: (qmail 23888 invoked by uid 1000); 21 Mar 2020 15:33:12 -0000
X-AntiVirus: Clean
Message-ID: <20200321153311.23887.qmail#gt-van-cus5.nmsrv.com>
From: x#x.com
To: support#mysite.co.uk
Subject: =?UTF-8?B?d2ViZm9ybSA=?=
Date: Sat, 21 Mar 2020 08:33:11 -0700
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="15848047911.6F3Ff.23881"
Content-Transfer-Encoding: 7bit
X-Spam-Score: 16
X-Spam-Bar: +
X-Spam-Report: Spam detection software, running on the system "admin.foo.com",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
##CONTACT_ADDRESS## for details.
Content preview: Date: Sat, 21 Mar 2020 08:33:11 -0700 MIME-Version: 1.0 Content-Type:
multipart/alternative; boundary="15848047910.05Ba9cd88.23881" [...]
Content analysis details: (1.6 points, 4.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
1.1 TRACKER_ID BODY: Incorporates a tracking ID number
0.0 T_TVD_MIME_NO_HEADERS BODY: No description available.
0.5 T_DKIM_INVALID DKIM-Signature header exists but is not valid
0.0 T_MIME_MALF Malformed MIME: headers in body
--15848047911.6F3Ff.23881
Date: Sat, 21 Mar 2020 08:33:11 -0700
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="15848047910.05Ba9cd88.23881"
Content-Transfer-Encoding: 7bit
--15848047910.05Ba9cd88.23881
Date: Sat, 21 Mar 2020 08:33:11 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
foo bar=
--15848047910.05Ba9cd88.23881
Date: Sat, 21 Mar 2020 08:33:11 -0700
MIME-Version: 1.0
Content-Type: text/html; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
some message=
--15848047910.05Ba9cd88.23881--
--15848047911.6F3Ff.23881
Date: Sat, 21 Mar 2020 08:33:11 -0700
MIME-Version: 1.0
Content-Type: image/jpeg; name="logo.jpg"
Content-Disposition: attachment; filename="logo.jpg"
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYF
BgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoK
CgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wgARCAAlAPwDAREA
AhEBAxEB/8QAHAABAAMBAQEBAQAAAAAAAAAAAAUGBwgDBAIB/8QAFgEBAQEAAAAAAAAAAAA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oYGlW
ymt5pgsATvmGrrlKUSYQ6JeQoKWUNXAwHOMiCDlBSv094tufqI8mjC9J34S1Qiez+tdGhGAuAciq
XluRB/vLAUZKY0SlsCE3non9GEEnsy28ljIWFQIgCoM4SUaOB8RH+/0BgpMchciwtlw0tr0D32ii
6c2qy0pOh/eD7jy6BHIY90MCsZMkK1lQbA9FsaXHMNt0CHkOk0LMC05dU0pMjUg2T/heSz467TtB
G8bAGLFmBgK87LI+HNeUM0tC4CQK7ZhA2dBcDnLWb44AlQFamEshj3wKNb1GiuE+L3ygv1N9HAje
NgDFizAwFedlkfDmvKGaWgriDVeC5uul8E8eAZeSgbN6AhOB78gA4msoyhIuGSnARObjZHTTrOu6
Xbc940SHQoGhSC8IZX+byWmuAgaAA0GHpsP65R2J54Vwx+SxnAGg+GOSMlrIkOCNtjwHYW/gqz/t
+gKzELpQQi9mB14XkQDhDowVY+nkcjH+gTZgcoABAPWKqa4ABRbBNNK+HFHCFbICRMg0Dwp0gaUk
CDOzDsPiobCLn2z0QvkDcJgXUYDduu5pDXVqn6bSMQ1xfRzAdAYXGyQ84792K4p0gaUkCDOzDsPi
qde9slEbBY1yeEEiYCoJ52jQAA0AGX00fP8AOAcQLVUAI6G5jICKyoICawxhDSAE0AABoDGkYRiF
JsZzSisQW4PYQGSoEF2pQy9VWENTnRMfP5IxEHpTIFrXlda/QTK7xRzsZE5Bh/P/2Q==
--15848047911.6F3Ff.23881--
The really weird part - is that the EXACT same code sends fine from one of my other servers. Yet, the MIME headers all look the same (minus having different part ids and date stamps obviously :)). I've got the host looking into this - in case its an Exim issue on their end, rather than my code. Seems very odd though!

SOAP attachments in WireMock

I'm using WireMock to mock a SOAP service.
It works great, but one of the services contains an attachment.
Is there any way to mock it with WireMock?
Thanks
Yes it's possible.
First, you can use SOAP ui to mock the response you are expecting with the attachment. [On the soap resource, right click: generate SOAP mock service]
On the mock created, in the response you should see a dummy body corresponding to the wsld. There you can click on attachment and add a file:
You run this mock and try to hit it manually with a soap request that should then appear on the request part.
It will produce for you the response with the attachment.
You can see the raw part looking like this:
Content-Type: multipart/related; type="application/xop+xml"; start="<rootpart#soapui.org>"; start-info="text/xml"; boundary="----=_Part_19_678369072.1513344309074",
MIME-Version: 1.0
------=_Part_19_678369072.1513344309074
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart#soapui.org>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getFileResponse xmlns:ns3="urn:eu:europa:ec:etrustex:integration:service:notification:v2.0" xmlns:ns2="urn:eu:europa:ec:etrustex:integration:service:filerepository:v2.0" xmlns="urn:eu:europa:ec:etrustex:integration:model:common:v2.0">
<ns2:fileWrapper>
<Content><inc:Include href="cid:test.txt" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></Content>
</ns2:fileWrapper>
</ns2:getFileResponse>
</S:Body>
</S:Envelope>
------=_Part_19_678369072.1513344309074
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-ID: <test.txt>
Content-Disposition: attachment; name="test.txt"
TEST
------=_Part_19_678369072.1513344309074--
Now, you can set up wiremock with something like this:
{
"request": {
"method": "POST",
"urlPattern": "/mockFileRepository"
},
"response": {
"status": 200,
"bodyFileName": "responseTest.raw",
"headers": {
"Content-Type": "multipart/related; type=\"application/xop+xml\"; start=\"<rootpart#soapui.org>\"; start-info=\"text/xml\"; boundary=\"----=_Part_19_678369072.1513344309074\"",
"MIME-Version": "1.0"
}
}
}
Pay attention the headers content-type should be the same as on the raw parts you got from soap ui.
the responseTest.raw looks something like this:
------=_Part_19_678369072.1513344309074
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart#soapui.org>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getFileResponse xmlns:ns3="urn:eu:europa:ec:etrustex:integration:service:notification:v2.0" xmlns:ns2="urn:eu:europa:ec:etrustex:integration:service:filerepository:v2.0" xmlns="urn:eu:europa:ec:etrustex:integration:model:common:v2.0">
<ns2:fileWrapper>
<Content><inc:Include href="cid:test.txt" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></Content>
</ns2:fileWrapper>
</ns2:getFileResponse>
</S:Body>
</S:Envelope>
------=_Part_19_678369072.1513344309074
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-ID: <test.txt>
Content-Disposition: attachment; name="test.txt"
TEST
------=_Part_19_678369072.1513344309074--
And voila!

Inline Images are Broken

I'm trying to send an email with an inline image. I've set the Content-ID and added a <img src="cid:image1#myemail"> to my html. The image arrives properly as an attachment, but mail clients show a broken image.
What am I doing wrong? The full source of the message is below:
Return-Path: <igal#lucee.org>
Received: from 128.149.80.230
by smtp.googlemail.com with ESMTPSA id i7sm9313707paf.9.2016.09.01.11.15.59
for <igal#lucee.org>
(version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
Thu, 01 Sep 2016 11:15:59 -0700 (PDT)
Date: Thu, 1 Sep 2016 11:15:54 -0700 (PDT)
From: igal#lucee.org
To: igal#lucee.org
Message-ID: <489410968.5.1472753755600.JavaMail.Admin#IS16>
Subject: [Test] LDEV-545 html 5.0.0.200
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_4_247149912.1472753754816"
X-Mailer: Lucee Mail
------=_Part_4_247149912.1472753754816
Content-Type: multipart/alternative;
boundary="----=_Part_3_913848408.1472753754815"
------=_Part_3_913848408.1472753754815
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Text Message
------=_Part_3_913848408.1472753754815
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Inline Image: <img src="cid:image1#myemail">
------=_Part_3_913848408.1472753754815--
------=_Part_4_247149912.1472753754816
Content-Type: image/jpeg; name=test-image.jpg
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=test-image.jpg
Content-ID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038hcyL1FUdL1ix1mxN5YTrLbhmUvgjBHXrVaHxRpk80aRSzMkjiOOf7PJ5Ls
TgASbdpyenPNP2NS7XK9N9Ng5l3NeisuPxFZTXr2sK3cskc3kOyWkrIr9wXC7RjPXNalTKEofErA
mnsFFFFQMKwtX/5Gvw/9bj/0XW7RWlOfI7+TX3poTVzzLSGutB0y3uLBCzawJbUYHC3PnP5bn22s
2fZBV4xto9l4g03TR/pEs9vY22TglmgRdxPrjcxPtXfUV3SzDmk5OO++u+qav6JWMlSsrXOANlf2
iavpC2cdl/aViWtIYp/MG+NAjAHaOSu38iauyeI0a50eHSNRjRZJooJdOMI82Nf4s55XAGOldlij
AznHPrUPGRl8cP6tbqn2XnvrqP2bWzOK0C+trfXtTim1xLd31SULYsYx5pOADyN3J9D2rtqTFLXP
XrKrLmSt/Xoi4x5VYKKKKwKCiiigAooooAKKKKACiiigAooooA//2Q==
------=_Part_4_247149912.1472753754816--
I found the problem. It is missing Content-Type: multipart/related;

Jasper webservice: Invalid resource descriptor

I try to upload a simple image via REST webservice to the jasper server.
This is the HTTP request/response, I'm getting "400 Bad Request: Invalid resource descriptor".
I tried to copy a valid resource descriptor from the repository and re-upload it but it gives the same error!
(The dots represent \r\n and \t chars.)
T 10.84.6.166:36057 -> 10.84.6.166:8080 [AP].
PUT /jasperserver/rest/resource/reports/Customers/3221/image01.gif HTTP/1.1.
User-Agent: useragent.
Host: 10.84.6.166:8080.
Accept: */*.
Cookie: JSESSIONID=5D8D24835E61ED65ABD982964243C06B.
Content-Type: multipart/form-data; boundary="72e01e9922f8bb1669638258c2a2a155".
Content-Length: 23796.
Expect: 100-continue.
.
T 10.84.6.166:8080 -> 10.84.6.166:36057 [AP]
HTTP/1.1 100 Continue.
.
T 10.84.6.166:36057 -> 10.84.6.166:8080 [AP]
--72e01e9922f8bb1669638258c2a2a155.
Content-Disposition: form-data; name="ResourceDescriptor".
Content-Length: 811.
Content-Type: text/plain; charset=UTF-8.
Content-Transfer-Encoding: 8bit.
.
<resourceDescriptor name="s2" wsType="img" uriString="/reports/Customers/3221/s2.png" isNew="true">.
.<label><![CDATA[serverattacks_13-06-01.png]]></label>.
.<creationDate>1373470272965</creationDate>.
.<resourceProperty name="PROP_RESOURCE_TYPE">.
..<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_PARENT_FOLDER">.
..<value><![CDATA[/reports/Customers/3221]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_VERSION">.
..<value><![CDATA[0]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_HAS_DATA">.
..<value><![CDATA[true]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_IS_REFERENCE">.
..<value><![CDATA[false]]></value>.
.</resourceProperty>.
</resourceDescriptor>.
--72e01e9922f8bb1669638258c2a2a155.
Content-Disposition: form-data; name="/reports/Customers/3221/s2.png".
Content-Length: 22544.
Content-Type: application/octet-stream.
Content-Transfer-Encoding: binary.
.
<long binary png contents>
--72e01e9922f8bb1669638258c2a2a155--.
T 10.84.6.166:8080 -> 10.84.6.166:36057 [AP]
HTTP/1.1 400 Bad Request.
Server: Apache-Coyote/1.1.
Pragma: No-cache.
Cache-Control: no-cache.
Expires: Thu, 01 Jan 1970 01:00:00 CET.
P3P: CP="ALL".
Content-Type: text/xml;charset=UTF-8.
Content-Length: 27.
Date: Thu, 11 Jul 2013 08:42:09 GMT.
Connection: close.
.
Invalid resource descriptor
Update:
I still don't know what's wrong but I finally got it working and released a Jasper PHP Library on github: http://blog.flowl.info/2013/jasper-php-library-on-github/
I tried to update jrxml on jasperServer. I found and buld java tests. I found working example of updating image on JasperServer.Mаy it is help уou.(With help of this example i wrote request for updating jrxml on jasperServer. And it is works!)
POST http://repsuite.cheby.ru:8080/jasperserver/rest/resource/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE HTTP/1.1
Content-Length: 5560
Content-Type: multipart/form-data; boundary=dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
Host: repsuite.cheby.ru:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Cookie: JSESSIONID=E485652B97C69549403D8CEEA0DC0855
Cookie2: $Version=1
--dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
Content-Disposition: form-data; name="ResourceDescriptor"
<resourceDescriptor name="JUNIT_IMAGE_FILE" wsType="img" uriString="/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE" isNew="true">
<label>jaspersoft logo</label>
<description>jaspersoft logo</description>
<creationDate>1308696383000</creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource</value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value>/SAMPLE_REST_FOLDER</value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value>0</value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value>false</value>
</resourceProperty>
<resourceProperty name="PROP_HAS_DATA">
<value>true</value>
</resourceProperty>
</resourceDescriptor>
--dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
Content-Disposition: form-data; name="/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE"; filename="jasperSoftLogo_2.jpg"
Content-Type: application/octet-stream
----Binary content of image----