Article ID: 124010, created on Dec 23, 2014, last review on Dec 24, 2014

  • Applies to:
  • APS 2.x

Symptoms

I'm seeing the following error when trying to edit or create a resource:

{
  "error": "std::runtime_error",
  "message": "Invalid \\u escape sequence"
}

Cause

There must be a more than two byte character in a string endpoint returns to you, examples:

  • some Japanese/Chinese characters (mostly 3 and 4 bytes)
  • some currency signs: € sign (0xE2, 0x82, 0xAC)

For example you during creation of a customer you may send balance property:

"balance": "40.399,64 €"

Creation fails with "Invalid \\u escape sequence" error, the endpoint returned 200 OK response to the contoller along with payload mirroring the one that was sent however the balance property is different:

"balance": "40.399,64 \u20ac"

The cause is that in PHP prior to 5.4 json_encode() automatically escaped unicode, in PHP 5.4 JSON_UNESCAPED_UNICODE was introduced:

http://php.net/manual/en/function.json-encode.php

Resolution

Upgrade PHP on endpoint to 5.4 and aps-php-runtime >= 2.0-340

70bf700e0cdb9d7211df2595ef7276ab 717db81efe94e616312b74fb03a5d474

Email subscription for changes to this article
Save as PDF