Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value:

4,821 views
Skip to first unread message

Geoff

unread,
Apr 18, 2012, 9:04:36 PM4/18/12
to ravendb
I'm getting the below error from json.net when storing my model:

System.InvalidOperationException was unhandled by user code
Message=Url: "/docs/Raven/Hilo/UserDataModels"

Newtonsoft.Json.JsonReaderException: Unexpected character encountered
while parsing value: . Line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue() in d:\Development
\Releases\Json\Working\Src\Newtonsoft.Json\JsonTextReader.cs:line 1117
at Newtonsoft.Json.JsonTextReader.ReadInternal() in d:\Development
\Releases\Json\Working\Src\Newtonsoft.Json\JsonTextReader.cs:line 557
at Raven.Json.Linq.RavenJObject.Load(JsonReader reader) in c:\Builds
\RavenDB-Stable\Raven.Abstractions\Json\Linq\RavenJObject.cs:line 149
at Raven.Database.Extensions.HttpExtensions.ReadJson(IHttpContext
context) in c:\Builds\RavenDB-Stable\Raven.Database\Extensions
\HttpExtensions.cs:line 50
at Raven.Database.Server.Responders.Document.Put(IHttpContext
context, String docId) in c:\Builds\RavenDB-Stable\Raven.Database
\Server\Responders\Document.cs:line 150
at Raven.Database.Server.Responders.Document.Respond(IHttpContext
context) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders
\Document.cs:line 49
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext
ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server
\HttpServer.cs:line 534
at
Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)
in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line
309

Source=Raven.Client.Lightweight
StackTrace:
at
Raven.Client.Connection.HttpJsonRequest.HanldeErrors(WebException e)
in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection
\HttpJsonRequest.cs:line 420
at
Raven.Client.Connection.HttpJsonRequest.ReadStringInternal(Func`1
getResponse) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight
\Connection\HttpJsonRequest.cs:line 289
at Raven.Client.Connection.HttpJsonRequest.ReadResponseString()
in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection
\HttpJsonRequest.cs:line 202
at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson()
in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection
\HttpJsonRequest.cs:line 630
at Raven.Client.Connection.ServerClient.DirectPut(RavenJObject
metadata, String key, Nullable`1 etag, RavenJObject document, String
operationUrl) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight
\Connection\ServerClient.cs:line 341
at
Raven.Client.Connection.ServerClient.<>c__DisplayClass10.<Put>b__f(String
u) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection
\ServerClient.cs:line 299
at Raven.Client.Connection.ServerClient.TryOperation[T](Func`2
operation, String operationUrl, Boolean avoidThrowing, T& result) in c:
\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection
\ServerClient.cs:line 222
at
Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String
method, Func`2 operation) in c:\Builds\RavenDB-Stable
\Raven.Client.Lightweight\Connection\ServerClient.cs:line 192
at Raven.Client.Connection.ServerClient.Put(String key,
Nullable`1 etag, RavenJObject document, RavenJObject metadata) in c:
\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection
\ServerClient.cs:line 299
at
Raven.Client.Document.HiLoKeyGenerator.PutDocument(JsonDocument
document) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document
\HiLoKeyGenerator.cs:line 148
at Raven.Client.Document.HiLoKeyGenerator.GetNextMax() in c:
\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document
\HiLoKeyGenerator.cs:line 113
at Raven.Client.Document.HiLoKeyGenerator.NextId() in c:\Builds
\RavenDB-Stable\Raven.Client.Lightweight\Document
\HiLoKeyGenerator.cs:line 83
at
Raven.Client.Document.HiLoKeyGenerator.GenerateDocumentKey(DocumentConvention
convention, Object entity) in c:\Builds\RavenDB-Stable
\Raven.Client.Lightweight\Document\HiLoKeyGenerator.cs:line 65
at
Raven.Client.Document.MultiTypeHiLoKeyGenerator.GenerateDocumentKey(DocumentConvention
conventions, Object entity) in c:\Builds\RavenDB-Stable
\Raven.Client.Lightweight\Document\MultiTypeHiLoKeyGenerator.cs:line
75
at
Raven.Client.Document.DocumentStore.<>c__DisplayClass2.<Initialize>b__1(Object
entity) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document
\DocumentStore.cs:line 363
at
Raven.Client.Document.DocumentConvention.GenerateDocumentKey(Object
entity) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document
\DocumentConvention.cs:line 251
at
Raven.Client.Document.InMemoryDocumentSessionOperations.GetOrGenerateDocumentKey(Object
entity) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document
\InMemoryDocumentSessionOperations.cs:line 626
at
Raven.Client.Document.InMemoryDocumentSessionOperations.StoreInternal(Object
entity, Nullable`1 etag, String id) in c:\Builds\RavenDB-Stable
\Raven.Client.Lightweight\Document
\InMemoryDocumentSessionOperations.cs:line 568
at
Raven.Client.Document.InMemoryDocumentSessionOperations.Store(Object
entity) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document
\InMemoryDocumentSessionOperations.cs:line 514
at
OnlineQuestionnaire.DocDataService.Controllers.UserController.Post(UserDataModel
model) in F:\Source\TeamHealth Recruiting\Online Questionnaire\Tools
\Prototyping\T4\OnlineQuestionnaire\OnlineQuestionnaire.DocDataService
\Controllers\UserController.cs:line 29
at lambda_method(Closure , Object , Object[] )
at
System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object
instance, Object[] arguments)
at
System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext
controllerContext, IDictionary`2 arguments)
at
System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult]
(Func`1 func, CancellationToken cancellationToken)
InnerException:


My code in the api controller post method is small:
// POST /api/User
public HttpResponseMessage<UserDataModel> Post(UserDataModel
model)
{
if (null == model) return new
HttpResponseMessage<UserDataModel>(HttpStatusCode.BadRequest);
Session.Store(model);
return new
HttpResponseMessage<UserDataModel>(HttpStatusCode.OK);
}

The model just has a few basic string properties. Ideas? Thanks!

Itamar Syn-Hershko

unread,
Apr 18, 2012, 9:18:10 PM4/18/12
to rav...@googlegroups.com
Are the client and server of the same version?

Justin A

unread,
Apr 18, 2012, 9:29:36 PM4/18/12
to rav...@googlegroups.com
I get this error when my website code is using v888 RavenDb.Client .. from nuget 

but the server is using v701.

mvmv

unread,
Apr 19, 2012, 12:16:31 AM4/19/12
to rav...@googlegroups.com
same here, I guess client and server need to be in same version?

Oren Eini (Ayende Rahien)

unread,
Apr 19, 2012, 2:46:42 AM4/19/12
to rav...@googlegroups.com
Yes, they need to.
Or, you can upgrade to 911 and use store.JsonRequestFactory.DisableHttpCompressiong = true;

Geoff

unread,
Apr 19, 2012, 10:32:38 AM4/19/12
to ravendb
Sorry, I thought I had email updates turned on, just saw these
messages.

Yeah it looks like I'm using RavenDB.Client 1.0.888 and seem to
remember version 800 on the server. For some reason the big font and
bold formatting on build 888 my eyes totally missed and treated it as
a header. Maybe a heading "Older versions" above everything else will
help idiots like me rushing through the server install :).

I'll try 888 on the server and report back. Right now our server
doesn't have any data in it but what is the recommendation on
upgrading the server? Should I stop the service (assuming uninstall
does), Raven.Server.exe /uninstall, delete everything, copy latest
over and restore any config changes (port etc.)? Once it has data I'm
assuming I'd add backup the Server\Data directory and restore it?

On Apr 19, 2:46 am, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:

Geoff

unread,
Apr 19, 2012, 11:41:08 AM4/19/12
to ravendb
Upgrading to 888 on the server fixed the issue. Thanks; will be sure
to keep these in sync going forward.

As to the upgrade process I did notice some updating related
powershell scripts though I wasn't sure if that was just for plugins
or not. Suppose it would be easy enough to write a powershell script
to do some of the server upgrade work.

Itamar Syn-Hershko

unread,
Apr 19, 2012, 4:44:17 PM4/19/12
to rav...@googlegroups.com
Powershell won't cut it, in 1.2 we will introduce a proper automated way to do updates

The current scripts are for upgrading the bundles
Reply all
Reply to author
Forward
0 new messages