I am stuck with one of problem.
XML and JSON response of REST call don't display correct Chinese or any other foreign language that we we are expecting because post call send other than English language. But Reponse XML or JSON always displayed as question mark.
I tried to Accept-charset,content-language, vary header but i didn't able to get exact language content as response.
POST call url have body part as below
{
"assignmentActivityId": "b1ff695f-1693",
"assignmentActivityTitle":"Test",
"assignmentActivityType":"INDIVIDUAL",
"profileId": "158a1f0a9",
"earnedPoints":2,
"evaluationComments": "我能吞下玻璃而不伤身体 check 2 19/02/2015",
"reviewerComments" : "reviewer ",
"status": "DRAFT",
"documents" : [{"documentUri":"/ContentRepository"}]
}
Get call URL should receive evaluationComments of as Chinese but it display ? question mark on response xml or json.
How do you display it?
If you do a console.log or alert, is it still wrong?
If yes, then it is not a display problem, the response is really damaged.
Mihai
There was charset problem.
JSP display charset and UTF-8 but DB stored the data on Latin1.
So i have change the DB setting for Charset from latin1 to UTF-8.
Now working fine all the character are displaying according to internationalization .
Related
Looking at the MS-OXPROPS, MS-OXCMSG and MS-OXCMAIL documentation, it is said that the user should include PidTagInternetCodePage to indicate the appropriate code page for the HTML content in order to parse it properly.
However, opening up the ole streams of the msg files, I could not find the 0x3FDE stream that indicates the code page id, but only found some semblance of a code page id in the compressed RTF stream (first line).
Am I looking at the streams wrongly or are the other properties hidden in other streams? If so, how do I look for them?
Thanks in advance.
The PidTagInternetCodePage property is not guaranteed to be present and is in no way required, especially if it is a Unicode MSG file. The HTML body can include the meta tag with encoding in the header, and even then, it won't be necessary if all Unicode characters in the HTML body are properly HTML-encoded (which is always a good idea).
I'm trying to pass a complete URL as a parameter to a java-based REST service (GET), but I'm not sure how to format it in order to avoid a "HTTP 400 Bad Request". I've tried Base64 encoding, but still get the 400 error. I think part of the problem is that the url contains a question mark, "?", since it seems to be fine if I remove that and pass the url as-is. I'm not sure what is the problem when its encoded.
example url - http://my.site.com/testing-service?some+parms
method annotations:
#GET
#Path("/{fullurl}")
#Produces("application/json")
public Response findByUrl(#PathParam("fullurl") String fullurl)
...
(I've updated the description with a little more detail per the first couple of comments)
Apparently the encoding approach was close, but Base64 (java or commons-code) didn't work for whatever reason (length perhaps?). I found switching to Base32 (commons-code) works for my situation.
I'm using Play Framework 2.3 and the WS API to download and parse HTML pages. For none-English pages (e.g Russian, Hebrew), I often get wrong encoding.
Here's an example:
def test = Action.async { request =>
WS.url("http://news.walla.co.il/item/2793388").get.map { response =>
Ok(response.body)
}
}
This returns the web page's HTML. English characters are received ok. The Hebrew letters appear as Gibberish. (Not just when rendering, at the internal String level). Like so:
<title>29 ×ר×××× ××פ××ת ×ש×××× ×× ×¤××, ××× ×©×××©× ×שר×××× - ×××××! ××ש×ת</title>
Other articles from the same web-site can appear ok.
using cURL with the same web-page returns perfectly fine which makes me believe the problem is within the WS API.
Any ideas?
Edit:
I found a solution in this SO question.
Parsing the response as ISO-8859-1 and then converting it to UTF-8 like-so:
Ok(new String(response.body.getBytes("ISO-8859-1") , response.header(CONTENT_ENCODING).getOrElse("UTF-8")))
display correctly. So I have a working solution, but why isn't this done internally?
Ok, here the solution I ended up using in production:
def responseBody = response.header(CONTENT_TYPE).filter(_.toLowerCase.contains("charset")).fold(new String(response.body.getBytes("ISO-8859-1") , "UTF-8"))(_ => response.body)
Explanation:
If the request returns a "Content-Type" header that also specifies a charset, simply return the response body sine the WS API will use it to decode correctly, otherwise, assume the response is ISO-8859-1 encoded and convert it to UTF-8
I have problem with ipn from paypal. I'm sending them data utf-8 encoded(e.g. "Naročilo št" as item name) and when somebody pays they send me response which is malformed: "Naro�~D�~Milo �~E¡t."(response claims that is UTF-8 encoded) and then when I try to validate that payment I get that it's invalid.
I've tried to change the "buy button" encoding on my paypal profile but it's not working(I still get response with wrongly encoded characters). Anybody have an idea how to fix that issue? And I would rather avoid transforming item names to plain ascii or something similar.
Solution by OP.
According to this
When the Servlet container receives the request, it always pass the request parameters to your program decoded in ISO-8859-1 encoding. (e.g. Browser encoded in UTF-8 but container decoded in ISO-8859-1.) Thus your servlet or JSP will always receive garbage for characters other than ISO-8859-1 encoding.
so the solution to my problem was acquiring request parameters that way:
String value = request.getParameter("mytext");
try{
value = new String(value.getBytes("8859_1"), "UTF-8");
}catch(java.io.UnsupportedEncodingException e){
System.err.println(e);
}
I need to update an order which is done via PUT method passing the order id as part of the https url string and a single parameter, the status_id.
https://mystore.mybigcommerce.com/orders/12345.json
I have tried several methods to pass the status_id value but no matter what I try "status_id=12" or formatted as JSON "{"status_id": 12,}" I always get the same response:
[{"status":415,"message":"The specified input content type is not valid."}]
I have also tried as a POST request passing the JSON or XML code as raw data but that method is not supported.
How am I supposed to pass that field=value pair? can I embed it in the url string?
I also tried it but it wouldn't work for me.
Any ideas?
In case you are wondering I am doing it within FileMaker with TROIUrl plugIn, not a very popular technology, but the GET method retrieving orders works like a charm
TURL_Put( ""; $url ;"status_id=12") (I have also tried other FM plugIns to no avail)
Don't get too caught up in the Filemaker part, I don't expect many people out there to be familiar with BigCommerce and Filemaker. I just need a generic answer.
Thanks
Commandline tool curl is worth a try. It supports put and https.
Mac OS X: curl already installed, call from FileMaker via AppleScript do shell script.
Windows: must be installed, call via Powershell.
It works for me using { "status_id": "3" } which means you probably need to put quotes around the actual number.
Also, it is a PUT operation and application/json which is part of the request content.
The error message received by the OP:
[{"status":415,"message":"The specified input content type is not valid."}]
Is saying that he did not supply the 'Content-Type' header in his request or that the header supplied is for a content type that is not allowed. For the OP's case using JSON he would need to include the header:
Content-Type: application/json
in his HTTPS request. This description can be found along with those of the other status codes you may see here:
https://developer.bigcommerce.com/api/status-codes