How to send a string with quotemarks in the RequestBody?

spring requestbody string example
spring @requestbody json object example
spring rest multiple @requestbody parameters, possible?
spring @requestbody json object example
postman send double quotes
spring json request body not mapped to java pojo
spring multiple @requestbody
post mapping with request body

I have the following API-method:

  public ResponseEntity<?> partialProjectUpdate(@PathVariable long id, @RequestBody EntryStatus status) throws DailyEntryNotFoundException {
    return dailyEntryService.partialDailyEntryUpdate(id, status);

EntryStatus is an enum:

public enum EntryStatus {

  private static Map<String, EntryStatus> namesMap = new HashMap<String, EntryStatus>(3);

  static {
    namesMap.put("OPEN", OPEN);
    namesMap.put("PROGRESS", PROGRESS);
    namesMap.put("CHECKED", CHECKED);
    namesMap.put("BOOKED", BOOKED);

  public static EntryStatus forValue(String value) {
    return namesMap.get(value);

  public String toValue() {
    for (Map.Entry<String, EntryStatus> entry : namesMap.entrySet()) {
      if (entry.getValue() == this)
        return entry.getKey();

    return null; // or fail

I call the method in typescript like this:

partialUpdateDailyEntry(dailyEntry: DailyEntry, status): Observable<any> {
    const statusName: string =;
    return this.http.patch(BASE_URL +, statusName, this.authService.setHeaders('application/json'))

statusName is a string, but the problem is that its getting sent without quotemarks via JSON. The RequestBody is for example OPEN instead of "OPEN" which gives me the following error:

JSON parse error: Unrecognized token 'OPEN': was expecting ('true', 'false' or 'null').

As stated thats caused by the fact that the string is sent without quotemarks.

I could fix that problem by adding the quotemarks manually to statusName like this:

const statusName: string = '"' + + '"';

But that cant be the proper solution, is there a better way to do it?

Try with

@JsonFormat(shape = JsonFormat.Shape.STRING)
public enum EntryStatus{

java, Try with @JsonFormat(shape = JsonFormat.Shape.STRING) public enum EntryStatus{ OPEN, PROGRESS, CHECKED, BOOKED, UNAVAILABLE; }. Spring @RequestBody example. The application binds request body parameters of a form POST and JSON post request to mapped method arguments. pom.xml src ├───main │ ├───java │ │ └───com │ │ └───zetcode │ │ ├───bean │ │ │ │ │ ├───config │ │ │ │ │ │

maybe you could put

namesMap.put("OPEN", OPEN);


namesMap.put("\"OPEN\"", OPEN);

Variables used in POST requests not properly being substituted in , The userId variable should be enclosed in quotation marks. this with both the Postman app and the runner, here is the request body below. You can access the response body as you would do with any other response type. Using the .string() method allows us to receive the data in string format from the response body. Using the RequestBody and ResponseBody classes is a bit more complex on your side, because you need to handle the request body creation yourself. The described scalars

You are adding the header that you are sending JSON, but "OPEN" is not a valid JSON value.

You should either change your headers:


Or change how you send it:

this.http.patch(BASE_URL +, { status: statusName});

And change your java backend to handle to receive the object and read the status

Or stringify it before sending it:

const statusName: string = JSON.stringify(;

Spring @RequestBody tutorial, Spring @RequestBody tutorial shows how to bind method parameters to The application binds request body parameters of a form POST and JSON post package com.zetcode.bean; public class User { private String name; private String Note that on Windows we need to escape the double quotes. To place quotation marks in a string in your code. In Visual Basic, insert two quotation marks in a row as an embedded quotation mark. In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark. For example, to create the preceding string, use the following code.

How to send double quotes in postman csv data file, user,pass "\"something\"","\"something\"" //here the outer double quotes tell the parser that its a string , and inside we write \" to escape it. # Request Body. If this parameter is set, its value will be sent as the body of the request. Only one RequestBody parameter is accepted - the first one. The name of the parameter will be used as the Content-Type header for the request. RequestBody does not work on GET or HEAD Requests, as they do not send a body.

Escaping double quotes in a pill : Workato Success Center, I'm trying to pass an HTTP Post Request with a data pill in the Request body, but it is throwing an error because of an invalid request body. When I look at the� Description According to #6745 it is possible to define POST request having a List of String as request body parameter. In the generated Java client, the argument is a String where a List<String> is expected.

JSON Stringify request body using raw - Help, Right now, I the request body with a json under “raw” and the We're using API Gateway and the request body needs to be stringified before sending. Make sure your request body is only this (no quotes around the variable� Request request; request.body() MediaType contentType;String content; RequestBody.create(contentType, content) String content; RequestBody.create(MediaType.parse("application/json"), content) Smart code suggestions by Codota}

  • I get the same error with this. It still expects a String in the RequestBody, so the RequestBody still needs to have quotemarks which it doesnt.
  • But if i send "OPEN" in the Body as JSON with postman like this it works, so shouldnt it be a valid JSON value?
  • @M.Dietz if it is a json so you have to send it with double quotes
  • @M.Dietz Postman probably sends "OPEN", I guess the angular HttpClient only uses JSON.stringify when the passed body argument is not a string. You are telling the HttpClient you are going to send a JSON, but then you don't ;). I added a third option you could try though, this adds quotes