Questions tagged [yii-rest]

Use for questions about any version of Yii Rest Api, an open-source MVC framework for writing Rest API's in PHP5+

Yii provides a whole set of tools to simplify the task of implementing RESTful Web Service APIs. In particular, Yii supports the following features about RESTful APIs:

Quick prototyping with support for common APIs for Active Record;

Response format negotiation (supporting JSON and XML by default);

Customizable object serialization with support for selectable output fields;

Proper formatting of collection data and validation errors;

Support for HATEOAS;

Efficient routing with proper HTTP verb check;

Built-in support for the OPTIONS and HEAD verbs;

Authentication and authorization;

Data caching and HTTP caching;

Rate limiting;

21 questions
4
votes
2 answers

REST API call for login on Yii2

I am starting to use yii2 and I am providing a REST Api from the web app. I could not find any documentation on how to provide login functionality using yii2 REST api. Previously in yii1, we used to have an action called actionLogin which takes in…
appcoder
  • 639
  • 1
  • 9
  • 19
3
votes
2 answers

Yii2 - Return Response during beforeAction

I am building a test API. I have created a Controller Page which extends from yii\rest\Controller. Actions needs to send a response. To access actions in this controller, a service_id value needs to be posted. If present I need to evaluate if that…
Eduardo
  • 1,781
  • 3
  • 26
  • 61
2
votes
1 answer

yii2 global behavior to check language in module

I have api module in Yii2 app. Before any reuqest I need to check did user send language in post or get request. If user did not send language then throw exception with 422 code. I have module Api.php. I should configure only for this module.
akmal
  • 23
  • 4
2
votes
1 answer

Yii2 REST URLs not working except GET

I tried to create a REST API by referring Yii2 REST GUIDE but unfortunately I got only GET method working. Example URL: http://dev.exp-yii.com/employee apart from the above URL everything else gives me a NOT FOUND (404) error page (Not even a JSON…
Praneeth Nidarshan
  • 1,704
  • 15
  • 21
2
votes
1 answer

Yii2 REST API find by field

This is api url. /api/web/v1/users/123 Find user by id. How to change rule to find by token, not by id? Here is a rule: [ 'class' => 'yii\rest\UrlRule', 'controller' => ['v1/users'], …
Alex Pavlov
  • 571
  • 1
  • 7
  • 24
1
vote
1 answer

Yii2 RESTful: Content Negotiation languages not work

I implemented a structure of API Rest with the models in Yii2. Everything works great for actions (index, create, update etc ...) and methods (GET, POST, PUT etc ..) but I have a problem with the ContentNegotiator class. Specifically, if I pass as a…
Alberto Favaro
  • 1,824
  • 3
  • 21
  • 46
1
vote
1 answer

Cant set pageSize limit in yii2 rest or activeDataProvider

I cant set value of ActiveDataProvider (pagination) pageSize in rest app in order to change items in per page. This is my sample code in controller class EndpointController extends ActiveController { public $modelClass = 'common\models\Endpoint'; //…
1
vote
1 answer

rest yii2 pretty url urlManager

My yii2 rest work fine with this request http://extractor-frontend.dev/property?id=JP000004 i would to work with this http://extractor-frontend.dev/property/JP000004 this is my urlManager in config/web.php urlManager' => [ 'enablePrettyUrl'…
Andrea Perdicchia
  • 2,786
  • 1
  • 20
  • 19
1
vote
1 answer

using yii rest api with default URL GET format rather than PATH format

I have a problem with a yii rest api. I configured it to work following the tutorial on the yii framework page, but after that i realised that my api works BUT NOT some big PORTIONS of my PAGE since it is based on the GET URL format rather than PATH…
MTurPash
  • 979
  • 1
  • 11
  • 18
1
vote
1 answer

Yii2 rest return a custom value

I've a question about the RESTfull service of yii2. in the cal view ( GET resource/{id} ) I want to return custom value that take the number of the current page for example host/resource?page=x (if it's set) , and it sum by one (x+1) untill the…
giovaZ
  • 1,432
  • 3
  • 20
  • 62
1
vote
0 answers

not able to create the record in yii json api

I am trying to learn yii and create an api. I am able to get the data but I am not able to create new record using my json object. This is what I get Here is my main.php in api config looks like
Asim Zaidi
  • 27,016
  • 49
  • 132
  • 221
0
votes
0 answers

Yii2 Rest API Batch update and filtering

I am looking to implement batch insert and update in my Yii2 Rest API. For single record updation, I am using the Rest API call as https://xxxxxx.com/api/web/v1/contacts/update/1 . It wil update the record with ID = 1 But Now I want to update…
saran varma
  • 141
  • 1
  • 1
  • 6
0
votes
1 answer

Yii2 advanced - enable pretty URL in module

I am learning how modules work in Yii2 and now I created the following module: gdpr. I can access the following route: /index.php?r=gdpr/user/index. However, I want to access the route like this: /gdpr/user/index. How can I achieve…
0
votes
1 answer

Yii2 RateLimiter header X-Rate-Limit-Reset has wrong value

I have been struggling to understand the logic behind Yii2's value for X-Rate-Limit-Reset header that is calculated in this line. The documentation states: X-Rate-Limit-Reset, the number of seconds to wait in order to get the maximum number of…
Hector
  • 68
  • 7
0
votes
1 answer

Yii2 Make endpoint accessible through web and rest api

A customer has requested to have the exact same endpoints available through web interface as well as through REST API. The same endpoint should be visible using web browser only when being logged in. When accessing it via REST API, a valid access…
kurt
  • 11
  • 5
1
2