A
A
Askar Fuzaylov2015-11-17 10:01:53
PHP
Askar Fuzaylov, 2015-11-17 10:01:53

How to send XML body using Guzzle?

I send like this

$this->client->post($this->api_url, [
            'body' => $this->createRequestBody($request->to, $request->text)
        ]);

createRequestBodyreturns XML
In response, I get a status of 500. This indicates that the request is not correct coming to the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Askar Fuzaylov, 2015-11-17
@ARACOOOL

This is how it works

$this->client->request('POST', $this->api_url, [
            'headers' => [
                'Content-Type' => 'text/xml;charset=UTF-8'
            ],
            'body' => $this->createRequestBody($request->to, $request->text)
        ]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question