Answer the question
In order to leave comments, you need to log in
How to send JSON in the body of a POST request?
I need to put json like this:
{
"records": [
{
"fields": {
"Name": "111",
"Phone": "222",
"Status": "333"
}
}
]
}
<?
$url = "адрес_запроса"; // URL-адрес POST
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode( $data ),
'header'=> "Content-Type: application/json\r\n" .
"Authorization: Bearer XXX\r\n"
)
);
$context = stream_context_create( $options );
$result = file_get_contents( $url, false, $context );
$response = json_decode( $result );
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question