@Multipart @POST("/crx/packmgr/update.jsp") @Headers("Content-Type: multipart/form-data; charset=UTF-8") fun updatePackage( @Part("path") path: String?, @Part("packageName") packageName: String, @Part("groupName") groupName: String, @Part("version") packageVersion: String = "", @Part("description") description: String = "", @Part("filter") filter: String, @Part("_charset_") charset: String = "UTF-8" ): Single<PackageResponse>
`
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: --> POST https://qa.author.st.com:8088/crx/packmgr/update.jsp http/1.1
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: Content-Type: multipart/form-data; charset=UTF-8
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: Content-Length: 1540
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: Host: qa.author.st.com:8088
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: Connection: Keep-Alive
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: Accept-Encoding: gzip
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: Cookie: login-token=61f72fad-2693-49e3-a89d-db37e7926d8e%3af16817d3-7f1f-4b3b-a0d5-57f4232b33e1_8d173c0bb246cf68%3acrx.default
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: User-Agent: okhttp/3.12.1
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO:
Jan 24, 2019 1:10:48 PM okhttp3.internal.platform.Platform log
INFO: --f30bd60b-95c6-464b-bb53-edf710141c5b
Content-Disposition: form-data; name="path"
Content-Transfer-Encoding: binary
Content-Type: text/plain; charset=utf-8
Content-Length: 32
/etc/packages/6D-temp/test-1.zip
--f30bd60b-95c6-464b-bb53-edf710141c5b
Content-Disposition: form-data; name="packageName"
Content-Transfer-Encoding: binary
Content-Type: text/plain; charset=utf-8
Content-Length: 4`
Server response
24.01.2019 10:44:33.969 *ERROR* [qtp504462445-94283] com.day.crx.packmgr.impl.support.HttpMultipartPost Error while processing multipart.
org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
browser request headers:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Content-Length: 1049
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary9QKaR8Q1as5jUUt7
Delete your explicit @Headers annotation. The content type is added with a boundary automatically for all @Multipart requests.
@JakeWharton
Thank You - it works.
Is it possible to set a custom boundary pattern? like --xxxxxxxx
If server expected for example timestamp
@VatslauX have you found any solution to this?
No - it looks it should be a feature request
@VatslauX @chnouman is this what you are looking for?
RequestBody requestFile = RequestBody.create(MediaType.parse("application/octet-stream"), file);
MultipartBody.Part fileFormData = MultipartBody.Part.createFormData("whatever the server expects", fileName, requestFile);
MultipartBody.Builder builder = new MultipartBody.Builder(timeStampBoundary).setType(MediaType.parse("multipart/form-data"))
.addPart(fileFormData)
Call<Object> call = postSomething(builder.build());
---------------------------------------------------------------------
// Post Call
@Post(endpoint)
Call<Object> postSomething(@Body RequestBody body);
guys I want to add a custom Boundary can you help me with that
I need a solution for this also. Need to add two additional headers but the upload fails if I have a @HeaderMap annotation and map, works when I don't but server uses additional header information for analytics
@dekanako >
guys I want to add a custom Boundary can you help me with that
see my answer above replace timeStampBoundary with your custom boundary
Most helpful comment
Delete your explicit
@Headersannotation. The content type is added with a boundary automatically for all@Multipartrequests.