skip to Main Content

I’m developing C# application to communicate with Magento. When I try to login to get Session ID to do stuff. I use C# code below.

My login code

using (MagentoService mservice = new MagentoService())
    {    
        loginResponse = mservice.login("admin", "admin123");
    }

It always throws me this error

System.ServiceModel.FaultException: 'SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://admin.mywebsite.com/index.php/api/v2_soap/index/?wsdl=1' : Premature end of data in tag html line 7

because my API request gets redirected to the website’s homepage every time.

Follow this link for more info of this error: Cannot login Magento service using C# [Magento 1.9.3.3] Error: Premature end of data in tag html line 7)

Is there any way to stop my API request from getting redirected? Also is it possible to do from client without interfering Magento settings?

2

Answers


  1. Chosen as BEST ANSWER

    I asked the server owner to disable redirect from the API request endpoint URL (https://admin.mywebsite.com/index.php/api/v2_soap/index/) and everything works fine


  2. On the Magento server side, here is what I had to set in the Apache vhost configuration :

    RewriteCond %{HTTP_HOST} ^admin.magento.biz$ [NC]
    RewriteCond %{REQUEST_URI} /api/
    RewriteRule ^ https://magento.biz%{REQUEST_URI} [L,R]
    

    It seems to be a known Magento bug with 2 parameters that’s collides :

    • Auto-redirect to Base Url
    • Use Custom Admin URL with a subdomain
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search