"The remote server returned an error: (412) Precondition Failed" using RavenDB in ASP.NET Web API

1,377 views
Skip to first unread message

Chad Thiele

unread,
Apr 6, 2013, 4:55:29 AM4/6/13
to rav...@googlegroups.com
I'm getting an error when hitting this asp.net web api endpoint I'm creating:

[HttpGet]
public async Task<IList<Venue>> Search(double lat, double lng, string keyword) {
var venues = await Session.Advanced.AsyncLuceneQuery<Venue>("Place/ByLocationAndKeyword")
.WithinRadiusOf(radius: 5, latitude: lat, longitude: lng)
.AndAlso().Search("Query", keyword)
.ToListAsync();

return venues.Item2;
}

My api base controller is based off of the example in the RavenDB docs. The only difference is that I use a RavenHQ hosted database (v2), like so:

var docStore = new DocumentStore { Url = "https://lark.ravenhq.com/databases[db-name]", ApiKey = "[api-code]" };

When I hit the endpoint I get an error:

"The remote server returned an error: (412) Precondition Failed."

I suspect the error is from RavenHQ... but I'd like to point out I have another endpoint to load a single venue by id, which seems to be retrieving successfully (have yet to really debug this, but initial calls are returning documents).

Here's the stack trace:

   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Raven.Client.Connection.HttpJsonRequest.<>c__DisplayClassc.<InternalReadResponseStringAsync>b__9() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 128
   at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1 getResponse) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 351
   at Raven.Client.Connection.HttpJsonRequest.<InternalReadResponseStringAsync>b__8(Task`1 task) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 128
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Oren Eini (Ayende Rahien)

unread,
Apr 7, 2013, 2:27:42 PM4/7/13
to ravendb
412 means that you have a bad API key


--
You received this message because you are subscribed to the Google Groups "ravendb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted

Kijana Woodard

unread,
Dec 24, 2013, 1:38:33 PM12/24/13
to rav...@googlegroups.com
@jason - fwiw, you replied to a thread from April.


On Tue, Dec 24, 2013 at 12:12 PM, Jason Wicker <jas...@influence.tv> wrote:
Chad,

We had the same error with RavenHQ. (I KNOW it isn't the API key --  Oren would too, if he cared enough to read your post). We get this when trying to use the Streaming API and use Attachments as well. It seems RavenHQ does not fully support the advanced API, or at least without some hacks. I started to get the same error when trying to use the 'Attachment' feature once we upgraded to version 2.5 (server-side). RavenHQ was unable to help so we had to abandon the attachment-approach. Yet another frustrating outcome.

It seems the Raven Client incorrectly treats some errors as 412 or 401, when I am absolutely certain the API key is correct --  perhaps 412 gets bubbled up for unknown errors.

I am sorry I don't have a fix for you, but hopefully knowing that there is an issue with RavenHQ and the advanced API, I can at least confirm that you are not going crazy :)




--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.

Oren Eini (Ayende Rahien)

unread,
Dec 25, 2013, 4:34:11 AM12/25/13
to ravendb
412 is only generated by RavenDB when you are doing something with API keys.

What build are you using to talk to RavenDB 2.5?

Oren Eini
CEO
Hibernating Rhinos
Office:    +972-4-674-7811
Fax:       +972-153-4622-7811



Reply all
Reply to author
Forward
0 new messages