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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:37:13+00:00 2026-06-08T01:37:13+00:00

I am attempting to build a Delphi XE2 DataSnap Rest server to be used

  • 0

I am attempting to build a Delphi XE2 DataSnap Rest server to be used as a 3rd party API for access to our DBMS.

I have extended the functionality of the sample methods provided when using the rest datasnap wizard in xe2 with authentication and authorization.

I can confirm that all the server methods I have written do pass back the data expected when accessed directly through the browser.

The issue comes from trying to authenticate to the server from a $.ajax() call.

When accessed from the browser address bar, you are prompted for the username and password and, when you enter “dev” for both, allows you to continue.

When setting the ajax() username and password params to “dev”, I am getting a HTTP 401 response.

I think I am doing it correctly, but here is the code snippet:

$("#contentdiv").click(function(){
        $.ajax({
            type:"GET",
            cache:"false",
            username:"dev",
            password:"dev",
            url:"http://192.168.0.2:8080/datasnap/rest/TServerMethods1/methodname/",
            dataType:"jsonp",
            statusCode: {
                200: function(data){
                    alert('success ');
                }
            }               
        });
});

If I turn off authentication, I can successfully get a HTTP 200 response (albeit with a syntax error in the JSON Delphi DataSnap is returning, but that is a question for a different time).

Also, what is worth know – if I log in manually and then run the ajax, it works – I am assuming that this is because the credentials are cached or some such.

Quite new to both these technologies, so be gentle.
If I’ve left something out that could be of import, let me know and I will get it up here.

  • 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-08T01:37:15+00:00Added an answer on June 8, 2026 at 1:37 am

    Your Ajax code uses JSONP, the server uses basic authentification.

    A comment on this answer says that JSONP cannot contain the USER / PWD headers which Basic Auth requires:

    Basic Authentication with jQuery.ajax request and jsonp

    The reason is (quote from the answer above):

    JSONP works differently, it’s a GET request via a tag include
    to get the file, so you’re not sending special headers or anything.

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

Sidebar

Related Questions

I am attempting to build an authentication mechanism using API keys for access. As
I am attempting to build a REST-type JSON API for my app, and while
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
I'm attempting to build a method call from strings that have been passed into
I have the following class file that I'm attempting to build. I'd like to
While attempting to build a website, i have gone through many online tutorials. Thanks
I'm attempting to build a login page for my website. I have managed to
I'm attempting to build a gem for interacting w/ the Yahoo Placemaker API but
I'm attempting to build a tree, where each node can have an unspecified amount
I'm attempting to build a currency converter function in PHP. I have all my

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.