user3119509
user3119509

Reputation: 175

"Client Error" message when trying to implement an Rest API View

I'm creating an API with Drupal to serve a angular application. The problem is, when I create the view with Rest export and try to access it (via browser or postman), it gaves me an "Client error" message (and nothing more).

I'm using drupal-8.7.6, running with PHP7.3, mysql and apache 2. But I've tried at nginx also and the error appeared again.

To reproduce it, just add some contents, enable the Restful web services, jsonm hal and create a view that exports rest data.

I expect to access the information via GET request (using browser, postman or any other way)

Upvotes: 2

Views: 793

Answers (3)

Shujat Munawar
Shujat Munawar

Reputation: 1677

  1. Go to your View
  2. Go to Format
  3. Click on Settings beside Serializer
  4. Finally check Json option and save.

You are done :)

Upvotes: 2

Nazmus Sakib
Nazmus Sakib

Reputation: 92

Go to the rest exports view, click on format setting and click accepted request format to json.

Upvotes: -2

user3119509
user3119509

Reputation: 175

find out what was happening

I was not specificating the format of output, so Drupal was searching for an html to serve. To workaround this, just add to url: ?_format=json, for example, if my view route is "/articles", it will be: http://drupal.dev/articles?_format=json

Upvotes: 1

Related Questions