springspring-bootspring-mvcpostman

Space getting replaced by new line (\n) in double quoted string passed as request body in REST API


I have a requirement to implement regular expression that accepts space in double quotes for email address. example, "unusual email with space"@domain.com. Please note the email is double quoted and is valid email.

I am testing my api with Postman and below is my request body:

{"data": 
    {   "id": "#customerId",
        "type": "customer s",
        "attributes": {
          "contactInformation" : {
            "emailAddresses" :
            [
              {
                "emailAddress" : "\"unusual email with space\"@domain.com"
              }
            ]       
          }
        }
     }
}

The request goes through and comes to my api controller but the space is replaced by new line (\n).

"\"unusual email with\nspace\"@domain.com"

My request header contains :

Content-Type: application/json Accept-Charset: UTF-8

Can someone please help how to get the exact same string with space?

Regards, Mahendra Rathod


Solution

  • if you replace space with \u0020 or %20 should be fine..!