Skip to content

Tag: guzzle

Guzzle service description json array

How can I set parameter in Guzzle service description to be a json array? This is what I have tried but is not working: Call: The json correct json structure to be send is this: Answer You have to write nested definitions as per JSON schema validation rules. I had done this with XML based requests. Let me try…

Guzzle returns stream empty body instead of json body

When I use Postman to make an API call I receive a JSON object..which is what I expected. However When I make same call with Guzzle like so: I get dump below from Guzzle Answer getBody() returns a stream. If you want to get all the content at once you can use getContents() method and decode json while at it

Guzzle 6 send multipart data

I’d like to add some data to a Guzzle Http Request. There are file name, file content and header with authorization key. but I get error Catchable Fatal Error: Argument 2 passed to GuzzleHttpPsr7MultipartStream::addElement() must be of the type array, string given, called in vendorguzzlehttppsr7srcMulti…

Proper way to send (POST) xml with guzzle 6

I want to perform a post with guzzle sending an xml file. I did not find an example. What I ‘ve done so far is : No matter what I try I get back error -1 which means that xml is not valid. XML that I send passes online validation though and is valid %100 Please help. Answer After some

Response logging in AWS PHP SDK v3

In v2 of the AWS PHP SDK, I was able to setup logging of request and response information by simply doing this: In v3, I cannot seem to find the solution. Middlewares do not seem helpful as they only fire before the request is sent, and thus I cannot access the response HTTP code. Guzzle v6 has this feature b…

Guzzle returns cURL error 3: malformed

I want to try out the guzzle library and am following through their quickstart tutorial to make http requests to an api. Yet it doesn’t seem to work, because I get the following error: Since I have never worked with cURL before, I don’t even know how to respond to that error message. Here is my co…