admin管理员组文章数量:1314488
We use the Feign java client to update YouTube videos with YouTube data API V3. When updating the video if the video title or description contains non-ASCII characters then either they are treated as blank spaces (EX: Ä Ö Ü ß ä ö ü) or displayed as ???? (ex: ಆಂಟೆನಾ ಸ್ಥಾಪನೆ) Below is the method we use for updating the video
@RequestLine("PUT /videos?part=snippet,status,statistics&alt=json")
@Headers({"Authorization: {authToken}", "Accept: application/json;charset=UTF-8"})
@Body("%5B{uploadVideoDTO}%5D")
Video updateVideo(@Param("authToken") @NotBlank String authToken, @NotNull VideoUploadDTO uploadVideoDTO);
Below are the request details with Feign logs set to full
Note: Earlier the Accept header was only application/json
during that time the request was also logged with ???? in place of non-ASCII characters and after changing this to application/json;charset=UTF-8
at least the request is logged correctly and I assume also sent correctly.
---> PUT ;part=status&part=statistics&alt=json HTTP/1.1
Accept: application/json;charset=UTF-8
Authorization: Bearer <BearerToken>
Content-Length: 332
{
"id" : "15JCs1F_j50",
"snippet" : {
"title" : "ಆಂಟೆನಾ ಸ್ಥಾಪನೆ",
"description" : "",
"categoryId" : "27",
"defaultLanguage" : "en",
"tags" : [ ]
},
"status" : {
"embeddable" : true,
"selfDeclaredMadeForKids" : false,
"privacyStatus" : "unlisted"
}
}
---> END HTTP (332-byte body)
And in the response, the title is just a bunch of ?
<--- HTTP/1.1 200 OK (1066ms)
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
content-type: application/json; charset=UTF-8
date: Thu, 30 Jan 2025 11:45:24 GMT
server: scaffolding on HTTPServer2
transfer-encoding: chunked
vary: Origin
vary: X-Origin
vary: Referer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 0
{
"kind": "youtube#video",
"etag": "R8vO2esK8oIAIuzfFBlpDqM5-XM",
"id": "15JCs1F_j50",
"snippet": {
"publishedAt": "2025-01-30T11:36:41Z",
"channelId": "UCNhb_-2JbrBf4TL5_G6MkIw",
"title": "?????? ???????",
"description": "",
"thumbnails": {
<thumbnail_details>
},
"channelTitle": "Pramod A G",
"categoryId": "27",
"liveBroadcastContent": "none",
"defaultLanguage": "en",
"localized": {
"title": "?????? ???????",
"description": ""
},
"defaultAudioLanguage": "en-US"
},
"status": {
<status>
},
"statistics": {
<statistics>
}
}
<--- END HTTP (1565-byte body)
Please help me fix this. We use java.HttpRequest
for uploading the video and with that, the Unicode characters are properly decoded. There also we are not setting any special headers apart from Content-Tpe: Application/json
and Content-Length
. So I guess the issue is with Feign. I also checked if we are using any custom decoders, We use JacksonDecoder
and by default, it decodes and encodes to UTF-8
so not sure what's wrong here.
本文标签: springNon ASCII characters not disaplayed when updating video with FeignStack Overflow
版权声明:本文标题:spring - Non ASCII characters not disaplayed when updating video with Feign - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741966934a2407603.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论