Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
¿Cómo hacer una solicitud de publicación de GuzzleHttp con cuerpo y encabezado?

No puedo entender cómo modificar este cURL en Laravel 5.8, obteniendo la respuesta {"code":"11", "message":"invalid Request found", "status":"DECLINED"} .

Aquí está mi código cURL que funciona bien (en cartero y navegador):

 $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.hylo.biz/Api/v1.0/Payment', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "orderId":"KJDHKSGIU768", "amount":"100", "redirect_url":"google.com" }', CURLOPT_HTTPHEADER => [ 'Authorization: Basic WUR1pYQ1hYY3U2Og2OGM6JJE5tWEDJhJDEwZReVE=', 'Content-Type: application/json', ], ]); $response = curl_exec($curl); curl_close($curl); echo $response;

Aquí está mi código laravel:

 public function process(Request $request) { // return $request['request']; $client = new \GuzzleHttp\Client(); $url = "https://api.hylo.biz/Api/v1.0/Payment"; $response = $client->request('POST', $url, [ 'headers' => [ 'Authorization' => 'Basic WUR1pYQ1hYY3U2Og2OGM6JJE5tWEDJhJDEwZReVE=', 'Content-Type' => 'application/json' ], 'form_params' => $request['request'] ]); return $response = $response->getBody(); }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

de esta manera esta funcionando

 public function process(Request $request) { $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.hylo.biz/Api/v1.0/Payment', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "orderId":"KJDHKSGIU768", "amount":"100", "redirect_url":"google.com" }', CURLOPT_HTTPHEADER => [ 'Authorization: Basic WUR1pYQ1hYY3U2Og2OGM6JJE5tWEDJhJDEwZReVE=', 'Content-Type: application/json', ], ]); $response = curl_exec($curl); curl_close($curl); }

y también olvidé agregar use Illuminate\Http\Request;

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!