Exposing the API end-points for CRUD Operations in Laravel Backpack - laravel-backpack

How can I expose api-end points for the CRUD controllers used for backpack so that I can reuse the operations in the controllers without having to code new ones, while adding necessary api features like JSON, authentication modes

Looks like Backpack routes work like API end-points for XHR requests, so adding a header HTTP_X-Requested-With with a value XMLHttpRequest causes backpack to return with JSON

Related

How to get URL from request within an action?

I'm writing a HATEOAS-driven REST API and it would be convenient to return responses from some actions with links to other resources.
As the REST API is currently implemented following a monolithic architecture, and in order to not only reduce redundancies but also simplify the job of migrating some parts to microservices, it would be nice if an action could send responses based on the URL that was routed to it.
So, does anyone know if ASP.NET core 2.1 offers any way to access the full URL that's routed to an action when a request is routed to said action?

Querying SalesForce DB Records using REST API

I have tried implementing like this to get data from SalesForce DB using the REST api,
uri= ...."/query?q=Select+Acc_Name__c+From+Account__c+where+Acc_ID__c+=+'123456'+Limit+5
HttpGet httpGet = new HttpGet(uri);
This is the syntax i found in here
URI
/vXX.X/query/?q=SOQL query
while this works, I don't really want to expose my query like this in uri, Is there an another efficient way to achieve the same operation using REST api ?
You can't modify the way the REST API works. You can implement your own methods via an Apex Restful Web Service. This would allow you to define a method that receives the querystring via a POST (you could even encrypt it first if you wanted to).
Exposing Apex Classes as RESTful Web Services

How to use POST method in Drupal 8 Views Rest Export?

Drupal 8 supports REST API exports in GET method. But How can define POST method in views rest export api? #Drupal8 #views
By its nature, views deliver information from the database to the user. They are not designed to take in data.
To be able to accept POST requests, activate module RESTful Web Services and REST UI.
The Rest UI
Editing a resource in the Rest UI
Doing so, you'll create endpoints for accepting POST data.

Use GuzzleHttp to create post request

I want to create post request to a webapp that does not have API endpoints.
I want to be able to login, fetch data and post data. I have just stumbled upon GuzzleHttp, but HTTP alone is so hard. The webapp is a laravel application. How can I do this? Or is there elegant way of doing this?
Try Goutte. It uses Guzzle under the hood, but provides higher level interface to deal with web sites.

Can one method in Symfony Controller take care of Rest and Web Request

I am developing web application using Symfony2.
Methods in Controller will be called from Web Application but at the same time I need to expose rest api for same functionality. For example Login and get data for a user.
Can one method be configured/written to server the same purpose.
Yes, you need to determine the format of your response (HTML, JSON) from the controller(s), based on a parameter from the request. Have a look at the official Routing documentation: http://symfony.com/doc/current/book/routing.html#book-routing-format-param
Now when it comes to REST applications, FOSRestBundle makes things very easy for you. It allows you to configure format agnostic controllers in bunch. This is well documented in their "The View Layer" section.