Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodecException: No suitable writer found for part [SPR-16601] #21142

Closed
spring-projects-issues opened this issue Mar 16, 2018 · 1 comment
Closed
Assignees
Labels
in: web type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 16, 2018

Marc-Christian Schulze opened SPR-16601 and commented

Following test case (full example attached):

Flux<DataBuffer> content = Flux.empty();

MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.asyncPart("file", content, DataBuffer.class).headers(h -> {
	h.setContentDispositionFormData("file", "someFile.bin");
	h.setContentType(MediaType.APPLICATION_OCTET_STREAM);
});

WebClient.create("http://whatever.de") 
		.post() 
		.uri("/any/path") 
		.contentType(MediaType.MULTIPART_FORM_DATA) 
		.body(BodyInserters.fromMultipartData(builder.build())) 
		.exchange() 
		.block();

Throws an exception:

org.springframework.core.codec.CodecException: No suitable writer found for part: file

Dependencies:

  • org.springframework:spring-webflux:5.0.4.RELEASE
  • io.projectreactor.ipc:reactor-netty:0.7.5.RELEASE

Affects: 5.0.4

Attachments:

Referenced from: commits 842c291

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 16, 2018

Rossen Stoyanchev commented

You don't need to use BodyInserters in this case. This works:

WebClient.create("http://whatever.de").post() 
		.uri("/any/path") 
		.syncBody(builder.build()) 
		.exchange() 
		.block();

That said what you tried should not fail, so I'm scheduling for a fix in 5.0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants