Adding new Jtoken to Json Jtoken

I have the following Json

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "required",
        "message": "Login Required",
        "locationType": "header",
        "location": "Authorization"
      }
    ],
    "code": 401,
    "message": "Login Required"
  }
}

What I am trying to do is add a new JToken Under "message": "Login Required" something like "RetryMessage": "Failed after 10 retries"

I found this How do you add a JToken to an JObject? which doesn't quite work I think because of the fact that error is a token and not an object but I'm not sure.

What I have tried:

var JsonObj = JObject.Parse(response);
var RetryMessageJson = JToken.Parse(@"{ ""RetryMessage"" : ""UnKnown""}");
JsonObj["error"]["message"].AddAfterSelf(RetryMessageJson);

I have tried several versions of the code above and they all come back with the following Error message:

Newtonsoft.Json.Linq.JProperty cannot have multiple values.
Jon Skeet
people
quotationmark

Unless the ordering really matters, I suspect you just want to make it another property of the error:

// Variable names edited to follow normal C# conventions
var jsonResponse = JObject.Parse(response);
jsonResponse["error"]["retryMessage"] = "Unknown";

With your sample JSON, that results in:

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "required",
        "message": "Login Required",
        "locationType": "header",
        "location": "Authorization"
      }
    ],
    "code": 401,
    "message": "Login Required",
    "retryMessage": "Unknown"
  }
}

people

See more on this question at Stackoverflow