Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:58:08+00:00 2026-06-09T15:58:08+00:00

I am trying to replicate a database using .NET classes (httpWebRequest) instead of curl.

  • 0

I am trying to replicate a database using .NET classes (httpWebRequest) instead of curl. Unfortunately, the cURL works, but the (assumably) same syntax in .NET fails with a 404 “Unauthorized to access or create database” error. Below is my code.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("sourceURL");
        request.Method = "POST";
        request.ContentType = "application/json";

        long ticks = DateTime.UtcNow.Ticks;

        string json = "{ \"_id\":\"database_replicate" + ticks + "\", \"source\":\"sourceURL/database\", \"target\":\"database\", \"create_target\":true, \"user_ctx\": { \"roles\": [\"_admin\"] } }";

        using (var writer = new StreamWriter(request.GetRequestStream()))
        {
            writer.Write(json);
            writer.Close();
        }

Then it fails right here, on the response:

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

I am replicating to and from localhost. I’ve tried passing the credentials using request.Credentials, but that doesn’t change the problem. Neither does passing the credentials explicitly in the url.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:58:09+00:00Added an answer on June 9, 2026 at 3:58 pm

    As it turns out, the problem was that my username and password weren’t being caught. Whether I tried passing them in as part of the url, or as a credential attribute, it wasn’t picking them up. I had to create an authorize header like this

    $authorization = [System.Convert]::ToBase64String([System.Text.ASCIIEncoding]::ASCII.GetBytes("username" + ":" + "password")) 
    $delRequest.Headers.Add("Authorization", "authType " + $authorization)
    

    to make it work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to replicate an example found on MSDN. I am using ASP.NET
i am trying to replicate data between two local database instance http://wiki.apache.org/couchdb/How_to_replicate_a_database As per
I am trying to replicate a table produced from a sybase database, I dont
I'm trying to replicate some of the functionality in Apple's avTouch, but I can't
I am trying to replicate a portion of an SQL Server 2008 database in
Trying to replicate the following query using Zend_Db_Select . Any pointers? SELECT compounds.id as
I am trying to replicate the Navigation Buttons which exist within the ASP.NET Site:
i am trying to replicate this jcrop demo . Everything works fine except, my
I am trying to replicate WMD Markdown Editor. I tried to modify WMD instead
I'm trying to replicate at least some of the functionality of Workgroup Manager using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.