我在使用Grails中的HTTPBuilder時遇到了問題。HTTPBuilder在Grails中編碼utf-8
代碼是這樣的。
def http = new HTTPBuilder("theURL")
http.request(method, ContentType.JSON) {
uri.path = "theURI"
headers.'Authorization' = "OAuth $accessToken"
headers.'Accept' = "application/json"
headers.'content-type' = "application/json;charset=utf-8"
response.success = { resp, json ->
result = json
}
}
return result
現在的反應是「Cobroñ1234」一個JSON,但我需要「CobroNº1234」
我試圖與捲曲和響應是好的「CobroNº1234」,這讓我覺得問題在於HTTPBuilder,而不是我的API來響應請求。
我認爲這是一個響應編碼的問題。
你打的端點是公共的嗎? – Opal
是salesforce中的認證API(但我刪除了片段中的這部分代碼) – dimartiro
您是否嘗試將'content-type'設置爲'application/json; charset = utf-8'? – dmahapatro