gpt4 book ai didi

java - 无效MimeType异常: Invalid mime type "{Content-Type}": does not contain '/'

转载 作者:行者123 更新时间:2023-12-02 08:50:42 28 4
gpt4 key购买 nike

以下是我的服务代码:

public ChangeEmailOutputDto changeEmail( ChangeEmailInputDto changeEmailInputDto) 
{
return changeEmailClient.changeEmail(changeEmailInputDto.getEmail(), changeEmailInputDto.getMemberId(), MediaType.APPLICATION_JSON_UTF8_VALUE, UUID.randomUUID(), "1");

}

还有我的客户端代码:

@FeignClient(name = "ChangeEmail",url = "${app.rest.changeEmail}")
public interface ChangeEmailClient
{
@PostMapping(value = "/{memberId}")
ChangeEmailResponseDto changeEmail(@RequestBody String username,
@PathVariable("memberId") String memberId,
@RequestHeader(value = "Content-Type") String contentType,
@RequestHeader(value = "x-correlation-id") UUID correlationId,
@RequestHeader(value = "tenant-id") String tenantId);

}

如何在 FeignClient 中设置 Content-Type

最佳答案

内容类型的 HTTP header 字段是 Accept,而不是 Content-Type。尝试在客户端代码中更改它:

@FeignClient(name = "ChangeEmail",url = "${app.rest.changeEmail}")
public interface ChangeEmailClient
{
@PostMapping(value = "/{memberId}")
ChangeEmailResponseDto changeEmail(@RequestBody String username,
@PathVariable("memberId") String memberId,
@RequestHeader(value = "Accept") String contentType,
@RequestHeader(value = "x-correlation-id") UUID correlationId,
@RequestHeader(value = "tenant-id") String tenantId);

}

关于java - 无效MimeType异常: Invalid mime type "{Content-Type}": does not contain '/' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60798722/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com