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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:33:00+00:00 2026-06-12T22:33:00+00:00

I need to call a JSON API for a BPM engine from my asp.ner

  • 0

I need to call a JSON API for a BPM engine from my asp.ner mvc web application . The API call to the BPM is constructed as follow:-

http://localhost:8080/jw/web/json/workflow/process/list?j_username=kermit&hash=9449B5ABCFA9AFDA36B801351ED3DF66&loginAs=' + username

where both the j_user & hash paramertes represents a master login username and password which are set at the BPM engine side.
Currently i am calling the API using java/script at the view level from my asp.net mvc:-

$(document).ready(function () {
    var fullurl = 'http://localhost:8080/jw/web/json/workflow/package/list?j_username=kermit&hash=9449B5ABCFA9AFDA36B801351ED3DF66&loginAs=' + username ;
    $.ajax({
        type: "GET",
        url: fullurl, 

        dataType: "JSONP",
        // contentType: "application/json; charset=utf-8",
        success: function (result) {

            $.each(result.data, function (key, val) {

                // Format the text to display.
             //   var str = val.packageName + ' | ' + val.packageId;
                var str = val.packageName ;
                // Add a list item for the product.
                $('<li/>', { text: str })
                .appendTo($('#products'));

            });
        }
    });


});

But i was told that exposing both the master-login username and password and also the LoginAS username which represents the username of the login user at the asp.net mvc is not secure, AND THAT I SHOULD PERFORM THE API CALL AT THE SERVER SIDE INSTEAD OF MAKING THE API CALL FROM A JAVASCRIPT.

but my question is how i can convert my above code to receive the JSON from the mvc controller side and then pass the JSON to the view?
Best Regards

  • 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-12T22:33:02+00:00Added an answer on June 12, 2026 at 10:33 pm

    You could use a WebClient to fire an HTTP request to the specified url:

    public class PackagesController: Controller
    {
        public ActionResult List()
        {
            using (var client = new WebClient())
            {
                var query = HttpUtility.ParseQueryString(string.Empty);
                query["j_username"] = "kermit";
                query["hash"] = "9449B5ABCFA9AFDA36B801351ED3DF66";
                query["loginAs"] = "some_username";
                var url = new UriBuilder("http://localhost:8080/jw/web/json/workflow/package/list");
                url.Query = query.ToString();
                string json = client.DownloadString(url.ToString());
                return Content(json, "application/json");
            }
        }
    }
    

    or you could use the new HttpClient introduced in .NET 4.5:

    public class PackagesController : AsyncController
    {
        public async Task<ActionResult> ListPackages()
        {
            using (var client = new HttpClient())
            {
                var query = HttpUtility.ParseQueryString(string.Empty);
                query["j_username"] = "kermit";
                query["hash"] = "9449B5ABCFA9AFDA36B801351ED3DF66";
                query["loginAs"] = "some_username";
                var url = new UriBuilder("http://localhost:8080/jw/web/json/workflow/package/list");
                url.Query = query.ToString();
                var response = await client.GetAsync(url.ToString());
                var result = await response.Content.ReadAsStringAsync();
                return Content(result, "application/json");
            }
        }
    }
    

    and from your javascript send an AJAX request to the aforementioned action:

    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                url: '@Url.Action("List", "Packages")', 
                type: 'GET',
                cache: false,
                success: function (result) {
                    $.each(result.data, function (key, val) {
                        var str = val.packageName;
                        $('<li/>', { text: str })
                            .appendTo($('#products'));
                    });
                }
            });
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I need to call http://website.com/pagestuff?var1=123&var2=abc and I need to capture the json data
I'm using MVC web Api for RESTful purpose. My controller methods return serialized Json
i need to consume a web api, which is located here http://46.253.202.174:8080/ws-api/v1/rest/zdata/codesByJurAndUsage?jur=Boston,%20MA&usg=barber I don't
I have got this result using json decode from an api call. but I
I have an api that I need to call that uses json-rpc-1.0 (I have
I have a Json response that I receive from an API call. It has
For a REST web service call using PUT, I need to send JSON that
In order to signout from my webapp, I need to call a json to
I need some help with my web service and json call.. stuck trying to
I need to call a json script using curl terminal. following is the path

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.