guzzle

laravel guzzlehttp - Server Exception in RequestException.php

你离开我真会死。 提交于 2019-12-25 07:06:40
问题 I am getting ServerException in RequestException.php line 107 when I make POST request to my API. I get following error - Server error: POST http://10.10.1.40:3000/auth/register resulted in a 500 Internal Server Error response: {"statusCode":500,"errorMessage":"[object Object]"} . I tried sending post request from REST Client and it works. Following is the trace in RequestException.php line 107 at RequestException::create(object(Request), object(Response)) in Middleware.php line 65 at

How get json Respone from Guzzle, post protected google spread sheet

吃可爱长大的小学妹 提交于 2019-12-25 04:24:48
问题 How to get response when I post request with Guzzle I use "guzzle/guzzle": "^3.9", $guzzle = new Client(); $postCell = $guzzle ->post('https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheetId . ':batchUpdate', [], $addProtectedRangeJson ) ->addHeader('Authorization', 'Bearer ' . $arrayAccessTokenClient) ->addHeader('Content-type', 'application/json') ; $postCell ->send() ->getBody(true) ; $contents = (string) $postCell->getBody(); // get body that I post -> my request, not response

How to disable URL encoding in Guzzle 6

匆匆过客 提交于 2019-12-25 03:09:05
问题 I'm working with pipedrive API and I want to make such a request: GET https://api.pipedrive.com/v1/deals(id,title,value,currency)?api_token=YOUR_API_TOKEN It works fine eg. when I do the request with a browser, but when I send the request with Guzzle I get response 501. I assume that it gets encoded in a way that's not recognized by Pipedrive API. Is there a way to disable URL encoding in Guzzle 6? 回答1: Seems like this is a bug and I'm not the only one facing this issue: https://github.com

Guzzle | Async requests | Invalid resource type error

二次信任 提交于 2019-12-25 01:34:35
问题 I am trying to chain http requests, where the second request is dependent on the response from the first. I came across Guzzle Client->sendAsync(). The error I get: exception: "InvalidArgumentException" file: "...\guzzlehttp\psr7\src\functions.php" line: 116 message: "Invalid resource type: array" Here's what I have so far: $client = new Client([...]); $headers = [...]; $req = new Psr7\Request('GET', '/api/someapi', $headers); $finalResponse = $client->sendAsync($req)->then(function(

Keycloak send email reset password 401 Unauthorized or 500 Internal Server Error

∥☆過路亽.° 提交于 2019-12-24 19:03:58
问题 Hi I have a problem with send email to reset password. I using Keycloak 4.8. In documencation I found: Send a update account email to the user An email contains a link the user can click to perform a set of required actions. PUT /{realm}/users/{id}/execute-actions-email And required params: id , realm and actions . I write method using Guzzle: $client = new \GuzzleHttp\Client(); $response = $client->request('put', 'https://myserwerkeycloak.com/auth/admin/realms/testrealm/users/a98e...00d1

set connect_timeout of elasticsearch php client

半城伤御伤魂 提交于 2019-12-24 17:25:22
问题 i want to configure a a small timeout between my elasticsearch php client to the my elasticsearch server. i tried to pass some parameters to the guzzle client but it seems this doesn't work. here is the code: $params = array(); $params['hosts'] = $hosts; $params['guzzleOptions']['connect_timeout'] = 2.0; $params['guzzleOptions']['timeout'] = 2.0; $this->elastica_obj = new Elasticsearch\Client($params); i searched and found that the problem might occured because the timeout is set in the cURL

Guzzle: Uncaught exception & memory leak

落爺英雄遲暮 提交于 2019-12-24 12:41:31
问题 I'm having weird issues while using Guzzle When I try to simulate an erroneous request (e.g. a request which returns a status code 404) Guzzle throws a ClientException containing all the details of why that request failed. When I try to catch this exception my script exits with a fatal error stating that I didn't catch the exception and it shows an XDebug trace stating that I had a memory leak somehow. My code looks like this: Note: httpClient is a valid instance of GuzzleHttp/CLient.

guzzle exception with .localhost domains

元气小坏坏 提交于 2019-12-24 10:11:03
问题 On my local machine I have two services (in laravel 5): userBox and mailBox. mailBox use userBox during login using library "guzzlehttp/guzzle": "~6.0" and restful API (mailBox send user credential and get info do user exists and have proper access). After .dev subdomains stopps working I decide to use .localhost subdomain so i have: userbox.localhost mailbox.localhost I make changes in /etc/apache2/extra/httpd-vhosts.conf but unfortunatley I get error: cURL error 6: Could not resolve host:

Race between pool requests in Guzzle

主宰稳场 提交于 2019-12-24 08:59:39
问题 I'm doing mutiple api concurrent requests using guzzle Pool. Everything's working fine. But I want to stop/avoid all requests if any of the requests responded. That is, I want to do some race between the requests. Is it possible using Guzzle in laravel? Here's what I've done so far: $requests = function(array $urls){ foreach ($urls as $url) { yield new Request('GET', $url); } }; $pool = new Pool($client, $requests($urls), [ 'concurrency' => 5, 'fulfilled' => function($response, $index) use (

Laravel 5: Guzzle with Chumper Datatable

血红的双手。 提交于 2019-12-24 07:33:21
问题 I was wondering if there's a way to integrate this with guzzle? I'm calling an external restful api. I'm new to Datatable so not sure if it's possible. Right now i'm just doing a foreach in my view. How to integrate this with chumper datatable? Controller public function getIndex() { $client = new \GuzzleHttp\Client(); $response = $client->get('http://api.company.com/members'); $body = json_decode($response->getBody()); $content = view('members')->with('members',$body); return Admin::view(