How to consume api using c# or jquery

Mohammad Qasim 576 Reputation points


I am using sharepoint 2019 ( FBA)

Solution required..
I have to consumel rest api using application.aspx on c# ( login page )

Api url :

Parameter it takes.

Username : test
Token: 122671
Password : abc1234

It should also take basic autorization value
User = admin
Password = 1gayaywhayabay890ba11

These are api paramater and basic authorizarion..( above mentioned )

Please help ,how can i consume this api using c# and jquery..

Note: i have checked api on post man
Working fine..
On authorization basic mode :
username admin
Password : 1gayaywhayabay890ba11

And on body

Username = test,Token=122671,
Password =abc1234

In this way,it works

But how can i consume it on login pge ( FBA)
On sharepoint 2019 on prem.

Please help me out.

Appreciate swift response


An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,377 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,577 questions
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 32,166 Reputation points Microsoft Vendor

    Hi @Mohammad Qasim ,
    You can refer to the following code to login sharepoint 2019

    private void SignInUser()  
        var mem = (MyMembershipProvider) Utils.BaseMembershipProvider();  
        var role = (MyRoleProvider) Utils.BaseRoleProvider();  
        if (!mem.ValidateUser(_userName, _password))  
        SecurityToken token = SPSecurityContext.SecurityTokenForFormsAuthentication  
                                         (new Uri(SPContext.Current.Web.Url),  

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. sadomovalex 3,626 Reputation points

    did I understand correctly that you need to call some custom API endpoint from codebehind (C# code which runs on server side) of login page which is used in Sharepoint FBA site? If yes you need to add event handler (e.g. button click) which will cause postback to the server. In handler of this event you need to write code which will send HTTP request to API using basic authentication - like you test it in Postman. Here you may find example how to do that (search for "C# HttpClient Basic authentication"):

    0 comments No comments