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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:26:18+00:00 2026-06-08T17:26:18+00:00

I’ve got pdf with a description of API. I must login into their webservice.

  • 0

I’ve got pdf with a description of API. I must login into their webservice. Webservice is based on REST protocol. To login into this webservice I have to call url like this:
http://api.webepartners.pl/wydawca/Authorize?login=test&password=pass

I have account and password. When I replace test and pass with my login and psw and past url into webbrowser it looks like is ok. No errors occur.
But I must do it programatically in C#.
In google I’ve found:
http://developer.yahoo.com/dotnet/howto-rest_cs.html

I try this code:

Uri address = new Uri(@"http://api.webepartners.pl/wydawca/Authorize");

            // Create the web request  
            HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;

            // Set type to POST  
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";

            // Create the data we want to send  
            //string appId = "YahooDemo";
            //string context = "Italian sculptors and painters of the renaissance"
            //                    + "favored the Virgin Mary for inspiration";
            //string query = "madonna";

            string userName = "mylogin";
            string passsword = "mypassword";

            StringBuilder data = new StringBuilder();
            //data.Append("appid=" + HttpUtility.UrlEncode(appId));
            //data.Append("&context=" + HttpUtility.UrlEncode(context));
            //data.Append("&query=" + HttpUtility.UrlEncode(query));
            data.Append("login=" + HttpUtility.UrlEncode(userName));
            data.Append("&password=" + HttpUtility.UrlEncode(passsword));

            // Create a byte array of the data we want to send  
            byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());

            // Set the content length in the request headers  
            request.ContentLength = byteData.Length;

            // Write data  
            using (Stream postStream = request.GetRequestStream())
            {
                postStream.Write(byteData, 0, byteData.Length);
            }

            // Get response  
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) // error
            {
                // Get the response stream  
                StreamReader reader = new StreamReader(response.GetResponseStream());
            }

And I got error in the line using (HttpWebResponse response = request.GetResponse() as ..

An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code

Additional information: The remote server returned an error: (405) Method Not Allowed.

Can anyone help me ?

Thanks

  • 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-08T17:26:19+00:00Added an answer on June 8, 2026 at 5:26 pm

    You are sending a POST request with username and password as part of the request body. But it seems that the web service expects a GET service where everything is in the URL of the request.

    String uriStr = @"http://api.webepartners.pl/wydawca/Authorize?login="
        + HttpUtility.UrlEncode(userName) + "&password=" + HttpUtility.UrlEncode(passsword);
    Uri address = new Uri(uriStr);
    HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
    
    // Get response 
    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) // error
    {
        // Get the response stream  
        StreamReader reader = new StreamReader(response.GetResponseStream());
    }
    

    …..
    …..

    GET http://api.webepartners.pl/wydawca/Authorize?from=2012-07-29%2013:47:05 HTTP/1.1
    Content-Type: text/xml; encoding='utf-8'
    Host: api.webepartners.pl
    Cookie: .ASPXAUTH=7521F26EBCE8CE487C6860C5E98248B540E5591BD6AE7EC936ECE29B0912AC49C71837B98D7972ABA9C868F18A0C6FCD1EB38B22BE86DBCCCDF8D56D0440170FECF497FF00A1B5D7B268EF6DF27B2B9DB806291E517654A136EC5617A67182DB3E3ECF0D8ADA6F3927C2F955A92E20B7BF7AE6D7DAE2AED0B0D9A7BD406C2CF4
    
    
    HTTP/1.1 403 Forbidden
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Type: text/html
    Expires: -1
    Server: Microsoft-IIS/7.5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Sun, 29 Jul 2012 11:47:03 GMT
    Content-Length: 1233
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>403 - Forbidden: Access is denied.</title>
    <style type="text/css">
    <!--
    body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
    fieldset{padding:0 15px 10px 15px;} 
    h1{font-size:2.4em;margin:0;color:#FFF;}
    h2{font-size:1.7em;margin:0;color:#CC0000;} 
    h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
    #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
    background-color:#555555;}
    #content{margin:0 0 0 2%;position:relative;}
    .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
    -->
    </style>
    </head>
    <body>
    <div id="header"><h1>Server Error</h1></div>
    <div id="content">
     <div class="content-container"><fieldset>
      <h2>403 - Forbidden: Access is denied.</h2>
      <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
     </fieldset></div>
    </div>
    </body>
    </html>
    

    That’s it?

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.