How to enable HTTP / 1.1 400 Bad Request in curl php

I need to click a single .aspx page url from php code that I am trying to use using curl, but I get the error below and there is no space in the url.

 HTTP/1.1 400 Bad Request Content-Type: text/html; charset=us-ascii Server: Microsoft-HTTPAPI/2.0 Date: Mon, 05 Oct 2015 08:31:13 GMT Connection: close Content-Length: 311 

Bellow is the curl code I'm trying to hit. Any authority will say why I get this error.

 $api_url = 'http://www.test/xyz/OnlineOrder.aspx?'; $url= $api_url . 'InvoiceNo=' . $invoice; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); echo $data = curl_exec($ch); echo $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
+5
source share
1 answer

I got the Http response 200 ok , I watched the URL carefully, and I found one parameter with a space that caused the wrong request. Any way, if you got something like a problem, remove the white space from url and there parameter is.

using urlencode($url);

+6
source

Source: https://habr.com/ru/post/1232950/


All Articles