Document URI for multi tenant

41 views
Skip to first unread message

SQLServerDBARavenNewbie

unread,
May 1, 2012, 7:06:08 PM5/1/12
to ravendb
Values for variables used below,
-- docId - docs/people/6CFCE938-8ABE-4927-8F6F-C46ACFCDC8F4
-- ravenUrl http://localhost:8080

var httpWebRequest =
(HttpWebRequest)WebRequest.Create(new Uri(new Uri(ravenUrl), docId));
httpWebRequest.Method = "PUT";
httpWebRequest.Headers.Add("Raven-Entity-
Name", collectionName);

using the above code I can insert documents into the default database
without issue.

However if I create a tenant database (TENANT) and try to insert the
document with docId of

TENANT/docs/people/6CFCE938-8ABE-4927-8F6F-C46ACFCDC8F4

I get a 400 Error

The remote server returned an error: (400) Bad Request.

at System.Net.HttpWebRequest.GetResponse()
at Uploader.Program.Main(String[] args) in Uploader.cs:line 59
Http Status BadRequest

<html>
<body>
<h1>Could not figure out what to do</h1>
<p>Your request didn't match anything that Raven knows
to do, so
rry...</p>
</body>
</html>

Any pointers on the URI structure needed to get the document to the
tenant database?

Thanks in advance

Oren Eini (Ayende Rahien)

unread,
May 2, 2012, 1:07:53 AM5/2/12
to rav...@googlegroups.com
http://localhost:8080/databases/TENANT_NAME is the root that you want to work with.

GET http://localhost:8080/databases/Northwind/docs/ people/6CFCE938-8ABE-4927-8F6F-C46ACFCDC8F4 

Etc.

why are you working with raw web request, though?

SQLServerDBARavenNewbie

unread,
May 2, 2012, 8:49:38 AM5/2/12
to ravendb

I realize that a raw web request may be like using a sledgehammer to
crack an egg, but in my case, I am using this as a small test platform
to exercise the Raven-SQL Index replication to get a sense of timing
for the latency between the last insert of a batch and the time it
takes for the index to return from stale status and in the process
complete the replication to SQL Server. This is just so that for
reporting services I can set the expectation that the reporting
solution will be asynchronous and that best/worst case, my reports
will be x hours or minutes behind the Raven Transactional DB.

I use a SQL Server stored procedure to basically build a string that
represents the document format I want to work with, then I fill in the
relevant values in the document from a SQL Server table and store the
final result in one final table. In this way I can precreate a batch
of documents of whatever size I need and then my command line app
reads these documents from SQL and inserts them into Raven via the web
request.

Thanks again for your assistance here and hopefully this may help
others coming from more of a traditional RDBMS DBA background.

Colm

On May 2, 1:07 am, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:
> http://localhost:8080/databases/TENANT_NAMEis the root that you want to
> work with.
>
> GEThttp://localhost:8080/databases/Northwind/docs/
> people/6CFCE938-8ABE-4927-8F6F-C46ACFCDC8F4
>
> Etc.
>
> why are you working with raw web request, though?
>
> On Wed, May 2, 2012 at 2:06 AM, SQLServerDBARavenNewbie <
>
>
>
>
>
>
>
> colm.ho...@gmail.com> wrote:
> >        Values for variables used below,
> >           -- docId - docs/people/6CFCE938-8ABE-4927-8F6F-C46ACFCDC8F4
> >           -- ravenUrlhttp://localhost:8080
Reply all
Reply to author
Forward
0 new messages