isarantoglou
1 month ago
601
6
Laravel

Send XML body with HTTP Client (Laravel 7)

Posted 1 month ago by isarantoglou

Hello,

I am trying to learn HTTP Client of Laravel 7 and I got stuck. I want to send a XML to an endpoint but I can't find any documentation (https://laravel.com/docs/7.x/http-client#introduction). As I understand the default behavior is JSON.

Here is my code:

$headers = [ .. ];

$xml = ... // Valid XML created with DOMDocument


Http::withHeaders($headers)->post('https://test.com/',
             $xml
        );

Also the response is XML.

Is this doable with the Http client or shall I use guzzle?

Thanks in advance, Ilias

Please sign in or create an account to participate in this conversation.