1

Sorry if this is really simple but I am new to REST requests. I am trying to make a GET request to a REST API I have been provided with but I am getting a 415 error (Unsupported Media Type).

Here is my (very basic) code :

<?php

header('Content-Type: application/json;charset=utf-8;');

$url = "https://opsview.somedomain.net/rest";
$response = file_get_contents($url);
echo $response;

?>

The API I am connected to says it supports json or xml so not sure why I am getting this error? Any ideas?

Any help will be much appreciated.

MattDrewery
  • 129
  • 1
  • 3
  • 13
  • 4
    Possible duplicate of [PHP file\_get\_contents() and headers](http://stackoverflow.com/questions/2107759/php-file-get-contents-and-headers) – cmorrissey Jan 27 '16 at 17:01
  • If you whant to do GET request to https://opsview.somedomain.net/rest don't use file_get_contents, use CURL instead http://php.net/manual/en/book.curl.php – Michał Fraś Jan 27 '16 at 17:02

0 Answers0