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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:26:19+00:00 2026-05-16T02:26:19+00:00

I need to call a method from a webservice, so I’ve written this code:

  • 0

I need to call a method from a webservice, so I’ve written this code:

 private string urlPath = "http://xxx.xxx.xxx/manager/";
 string request = urlPath + "index.php/org/get_org_form";
 WebRequest webRequest = WebRequest.Create(request);
 webRequest.Method = "POST";
 webRequest.ContentType = "application/x-www-form-urlencoded";
 webRequest.
 webRequest.ContentLength = 0;
 WebResponse webResponse = webRequest.GetResponse();

But this method requires some parameters, as following:

Post data:

_username:'API USER',         // api authentication username

_password:'API PASSWORD',     // api authentication password

How can I add these parameters into this Webrequest?

  • 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-16T02:26:20+00:00Added an answer on May 16, 2026 at 2:26 am

    If these are the parameters of url-string then you need to add them through ‘?’ and ‘&’ chars, for example http://example.com/index.aspx?username=Api_user&password=Api_password.

    If these are the parameters of POST request, then you need to create POST data and write it to request stream. Here is sample method:

    private static string doRequestWithBytesPostData(string requestUri, string method, byte[] postData,
                                            CookieContainer cookieContainer,
                                            string userAgent, string acceptHeaderString,
                                            string referer,
                                            string contentType, out string responseUri)
            {
                var result = "";
                if (!string.IsNullOrEmpty(requestUri))
                {
                    var request = WebRequest.Create(requestUri) as HttpWebRequest;
                    if (request != null)
                    {
                        request.KeepAlive = true;
                        var cachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
                        request.CachePolicy = cachePolicy;
                        request.Expect = null;
                        if (!string.IsNullOrEmpty(method))
                            request.Method = method;
                        if (!string.IsNullOrEmpty(acceptHeaderString))
                            request.Accept = acceptHeaderString;
                        if (!string.IsNullOrEmpty(referer))
                            request.Referer = referer;
                        if (!string.IsNullOrEmpty(contentType))
                            request.ContentType = contentType;
                        if (!string.IsNullOrEmpty(userAgent))
                            request.UserAgent = userAgent;
                        if (cookieContainer != null)
                            request.CookieContainer = cookieContainer;
    
                        request.Timeout = Constants.RequestTimeOut;
    
                        if (request.Method == "POST")
                        {
                            if (postData != null)
                            {
                                request.ContentLength = postData.Length;
                                using (var dataStream = request.GetRequestStream())
                                {
                                    dataStream.Write(postData, 0, postData.Length);
                                }
                            }
                        }
    
                        using (var httpWebResponse = request.GetResponse() as HttpWebResponse)
                        {
                            if (httpWebResponse != null)
                            {
                                responseUri = httpWebResponse.ResponseUri.AbsoluteUri;
                                cookieContainer.Add(httpWebResponse.Cookies);
                                using (var streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
                                {
                                    result = streamReader.ReadToEnd();
                                }
                                return result;
                            }
                        }
                    }
                }
                responseUri = null;
                return null;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one has me stumped. I need to call an activity method from within
I need to call an webservice method from my excel macro. can any on
I need to call a method and pass an object from my custom UITableViewClass
I need a help from ur side. Actually I need to call a method
This is hopefully a softball syntax question: I need to call a method with
Need to call web method, from web service. but name of method is unknown
I need to make a call to a json webservice from C# Asp.net. The
I need to call methods from ANALYS32.XLL Excel add-ins for analysis toolpak into mu
I need to call some methods in Wininet.dll from a Java program. I can
I need to call a method I have defined as: -(IBAction)next:(id)sender{ ... } I

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.