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 7621685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:15:25+00:00 2026-05-31T04:15:25+00:00

I am experiencing a problem while POSTing to a resource which is protected by

  • 0

I am experiencing a problem while POSTing to a resource which is protected by basic access authentication.
Here is the code, I am using @mikeal’s request:

request.post({
  uri: "http://user:password@mysite.com/resource",
  json: {
    "id": "1",
    "par1": "a",
    "par2": "b"
  }
}, function (error, response, body) {
  console.log(error);
  console.log(response);
  console.log(body);
});

I have { [Error: Parse Error] bytesParsed: 0 } in error and undefined in both response and body. If I remove the “user:password” part I correctly get a 401 HTTP Basic: Access denied.

Do you know if there’s a way to POST JSON to a protected resource like in my case? If not, I believe I’ll have to go the http module way, but I’m leaving that as a final resource since it’s a lot more verbose.

UPDATE: To have this as simple as possible I’ve moved this file in a new directory and did a npm install request. The problem went away, I checked from where the byteParsed come from and found it’s in “formidable” which is required by express, which I had in the directory where I was running this test. A bit confused right now.

  • 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-05-31T04:15:26+00:00Added an answer on May 31, 2026 at 4:15 am

    You must add an header to your request with this rules:

    http://en.wikipedia.org/wiki/Basic_access_authentication

    Basically you must encode the string: username:password in base64 and add encoded string in an http header:

    Authorization: Basic “Base64(username:password)”

    I don’t know if is possible add header with jquery or javascript. Sorry.

    Look here: http://api.jquery.com/extending-ajax/#Transports

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

Sidebar

Related Questions

I am experiencing a problem with the following code in some versions of Internet
I'm experiencing this weird problem which my scrollbar jumps by itself to somewhere that
We are experiencing a performance problem when communicating with the active directory using System.DirectoryServices.
i'm currently experiencing a little problem. I'm using nhibernate with around 40 entities mapped
I am experiencing a problem while choosing Yes on my MessageBox with buttons Yes
Hello the problem i'm experiencing is when I attempt to call javascript function. Using
I'm experiencing a strange problem while trying to use the Ajax.BeginForm method of ASP.NET
I'm experiencing a problem while trying to use google maps api v3 (with marker
Problem description After a while of running my java server application I am experiencing
I'm currently experiencing a problem while trying to set up a project to deploy

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.