Curl Bad Request Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings curl 22 the requested url returned error 400 bad request and policies of this site About Us Learn more about Stack Overflow
Php Curl Bad Request
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Php Curl Http/1.1 400 Bad Request
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Php Curl Http Error 400. The Request Is Badly Formed.
only takes a minute: Sign up How to resolve HTTP/1.1 400 Bad Request in curl php up vote 1 down vote favorite I have to hit one .aspx page url from php code i am trying to hiting using curl but i am getting bellow error and there is no white space in url. HTTP/1.1 400 Bad Request Content-Type: text/html; curl post 400 bad request 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 code of curl which i am trying to hit.so any body will tell why iam getting 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); php curl share|improve this question asked Oct 5 '15 at 8:44 Sanjay Nakate 6681436 How is the target service specified? –jossif Oct 5 '15 at 8:57 that is the company genrate's the bar code's for generated order –Sanjay Nakate Oct 5 '15 at 9:34 I'm thinking of the interface. How's that specified? HTTP method, parameters, headers, auth etc. –jossif Oct 5 '15 at 9:40 target service dont have any api i just have to hit there url with some parameters like i have mentioned in the question. –Sanjay Nakate Oct 5 '15 at 9:51 Basically, your HTTP request seems to be fine a
here for a quick overview of the curl 400 bad request php site Help Center Detailed answers to any questions you php curl post 400 bad request might have Meta Discuss the workings and policies of this site About Us Learn http/1.1 400 bad request curl more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags http://stackoverflow.com/questions/32944441/how-to-resolve-http-1-1-400-bad-request-in-curl-php Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up 400 - Bad Request in Curl [closed] up vote 2 http://stackoverflow.com/questions/13764623/400-bad-request-in-curl down vote favorite 1 It seems like im getting a problem when Im trying to send a request to a server in php. The http api request is something like this: http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14&apiKey=p9ycn9cxb2zp3k3gfvbf5aym&cid=55505&locale=en_US&hotelId=122212&stateProvinceCode=%20NV%C2%A4cyCode=USD&arrivalDate=12/27/2012&departureDate=12/28/2012&room1=2,&room2=2,18,15&room3=3,16,16,15&room4=3,&includeDetails=true&includeRoomImages=true I have the following part of my code in php where I believe the error is occuring: $url = 'http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14'; $url .= '&apiKey=p9ycn9cxb2zp3k3gfvbf5aym'; $url .= '&cid=55505'; $url .= '&locale=' . $locale . '&hotelId=' . $hotelid . '&stateProvinceCode=' . $state . '¤cyCode=USD'; $url .= '&arrivalDate=' . $datefr . '&departureDate=' . $dateto . '&' . $details . '&includeDetails=true&includeRoomImages=true'; $header = "Accept: application/json"; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $retValue = curl_exec($ch); $response = json_decode(curl_exec($ch)); $ee = curl_getinfo($ch); print_r($ee); print_r($retValue); This is what I get from the print_r(curl_getinfo($ch)) statement: Array ( [url] => http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14&apiKey=p9ycn9cxb2zp3k3gfvb
here for a quick overview of the site Help Center Detailed answers to any questions you might have http://stackoverflow.com/questions/24569281/error-400-bad-request-when-i-use-php-curl Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, bad request just like you, helping each other. Join them; it only takes a minute: Sign up Error 400 Bad request when I use PHP CURL up vote 1 down vote favorite When I CURL in PHP. With appropriate headers and fields but It will give me error Error 400 Bad request. Why this error becomes? HTTP/1.0 400 400 bad request Bad request Cache-Control: no-cache Connection: close Content-Type: text/html 400 Bad request Your browser sent an invalid request. 1 Header Request $header[] = "Accept:application/json, text/javascript, */*; q=0.01"; $header[]="Accept-Encoding:gzip, deflate"; $header[] = "Cache-Control:max-age=0"; $header[]= "Accept-Language:en-US,en;q=0.5"; $header[] = "Content-Length:37"; $header[]="Content-Type:application/x-www-form-urlencoded; charset=UTF-8"; $header[]="Cookie:__qca=P0-116849880-1387336057175; __utma=140029553.335591273.1387336057.1389609300.1389617402.102; __utmz=140029553.1389617402.102.89.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); _ga=GA1.2.335591273.1387336057; sgt=id=3380ce36-a139-4845-bd20-5bb3fd4174ec; usr=t=qrthm51g2UyV&s=QtuIYj84zEOR"; $header[]="X-Requested-With:XMLHttpRequest"; CURL Code $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_POST, $fields); curl_setopt($ch, CURLOPT_, $value); $response=curl_exec($ch); curl_close($ch); If you want any further data please comment I will explain in detail. php curl share|improve this question asked Jul 4 '14 at 7:51 Sadikhasan 11.3k73168 Please show the request headers. –DanFromGermany Jul 4 '14 at 7:53 could you show us the actual code? –Kita Jul 4 '14 at 7:53 check the https. –Imat Jul 4 '14 at 7:59 @Imat do you mean http or https? It's http –Sadikhasan Jul 4 '14 at 8:01 @Sadikhasan sometimes you need to use this. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); please check also if the server you're request