N
N
nevesomostjke2022-03-21 08:03:42
PHP
nevesomostjke, 2022-03-21 08:03:42

Why can't I display the request body?

A GET request comes to my site:

<request uri="https://owa.bushiyama.ru/call_events/">
<header name="Content-Type">application/json; charset=utf-8</header>
 <header name="X-Client-ID">client_id</header>
<header name="X-Client-Sign">sign</header>
<body>{"state":"new","type":"incoming","session_id":"76981273981237","timestamp":"1511753600","from_number":"+74951234567","request_number":"+74991234567"}</body>
</request>


I'm trying to output a request:
$data = request()->all();
print_r($data);


In response, I get:
<response status="200"><header name="Date">Mon, 21 Mar 2022 04:33:21 GMT</header>
<header name="Server">Apache</header>
<header name="Cache-Control">no-cache, private</header>
<header name="Set-Cookie">XSRF-TOKEN=</header>
<header name="Set-Cookie">laravel_session=session</header>
<header name="Content-Length">0</header>
<header name="Keep-Alive">timeout=120, max=999</header>
<header name="Connection">Keep-Alive</header>
<header name="Content-Type">text/html; charset=UTF-8</header>
<body><![CDATA[]]></body></response>

I need to get a JSON array that is sent to my server in the body of the body tag
. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gerasimov, 2022-03-21
@nevesomostjke

When contacting https://owa.bushiyama.ru/call_events/ there is a redirect to https://owa.bushiyama.ru/call_events (without a slash at the end) - when redirecting, data is lost and the request goes by the GET method (without BODY) and $request()->all() will be empty

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question