Hello I want to send a request using Kurl to follow the link (externally the link looks like

<a id="ctl00_plhMain_lnkSchApp" class="purplelink" href="javascript:__doPostBack('ctl00$plhMain$lnkSchApp','')">Далее</a> 

I pass a post request:

  curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,'некий пост-текст'). 

All the request data that is sent is taken from firebug, it clearly states that this is a post method. But as a result, the server returns

HTTP / 1.1 405 Method Not Allowed
Allow: OPTIONS, TRACE, GET, HEAD
Content-Length: 1564 Content-Type: text / html
Server: Microsoft-IIS / 6.0 X-Powered-By: ASP.NET
Date: Thu, 01 Sep 2016 16:45:55 GMT

that is, the POST method is not allowed. I can not understand what the problem is: either I do not correctly set the request, or indeed the method is not needed here, maybe there is another way to follow the link?

Closed due to the fact that off-topic participants Dmitriy Simushev , pavel , Streletz , Bald , Denis Sep 2 '16 at 6:09 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Dmitriy Simushev, pavel, Bald, Denis
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Response code 405 means that the request cannot be sent to this URL with the method you use. Moreover, the Allow header explicitly says that only queries with options OPTIONS , TRACE , GET , HEAD are expected. - Nofate
  • I understand, but firebug indicates that when you follow this link, post data was transmitted by a method. It turns out he is lying? - Roma Tulaydan

1 answer 1

I guess you should pass the correct Content-Type and the correct CURLOPT_POSTFIELDS