Я пытаюсь использовать Dynamics CRM Web API.Я получаю следующую ошибку:
An error occurred while validating input parameters: Microsoft.OData.ODataException: Invalid JSON. A token was not recognized in the JSON content.
При выполнении этого кода:
JObject jObject = new JObject();
jObject["content"] = "Test";
jObject["title"] = "Title";
jObject["createdon"] = DateTime.Now;
jObject["modifiedon"] = DateTime.Now;
jObject["knowledgearticleviews_date"] = DateTime.Now;
jObject["rating_date"] = DateTime.Now;
jObject["knowledgearticleid"] = Guid.NewGuid().ToString();
var client = new RestClient(Settings.DynamicsApiUrl + "/knowledgearticles");
var request = new RestRequest(Method.POST);
request.AddParameter("authorization", string.Format("Bearer " + _authToken), ParameterType.HttpHeader);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddBody(jObject.ToString());
IRestResponse response = client.Execute(request);
if(response.StatusCode == HttpStatusCode.BadRequest)
throw new Exception(response.Content);
jObject.ToString () равно:
{
"content": "Test",
"title": "Title",
"createdon": "2018-12-13T16:37:00.9897187+10:00",
"modifiedon": "2018-12-13T16:37:00.9897187+10:00",
"knowledgearticleviews_date": "2018-12-13T16:37:00.9897187+10:00",
"rating_date": "2018-12-13T16:37:00.9897187+10:00",
"knowledgearticleid": "56f42203-6872-4ac5-b4af-33132607833b"
}