My client asked me to develop a authenticated restful PHP Api which will read mysql query as a request and sends result set as a json response. But this api should allow to read only select queries.If any query with update/drop/truncate etc .. then it should through some error message like no permission etc.. But is it possible to read mysql queries as a query string ? Any help / suggestions would be greatly appreciated.
Related
In its most basic form, what I want to do is access data on my web server, from an Android App I'm developing (to be clear, different apps accesses the same data set).
To be more specific, I would like to set up my Web Server so that it returns a JSON String, in response to an HTTP GET request sent from the app. (That's not a requirement by any means, it just seems like how most APIs work).
So far, it seems I need a Web Framework with an MVC, like Ruby on Rails that uses a controller that can decide what to do with an HTTP GET request.
What I don't quite understand yet (not that I understand what I've said so far), is this:
How the data is stored (I know I can use a database, but I'd like to know the best/other options)
How to get query parameters from the URI
How to retrieve the data
How to organize the data into a JSON object/string
How to send the JSON string in response to the GET request
Obviously, I'm not a web development expert. I'm trying to learn, but I don't have the experience yet to even know what to search for. So I appreciate any help and resources you may have.
I've a requirement. I have a REST API using spring-mvc in which there is a POST method to insert data into MySQL database. I checked it through postman client and results got inserted into MySQL database. Now I've one more spring project say InsertMongo in which the details are inserted into MONGODB as documents. So, i need to invoke my REST API in that spring project InsertMongo such that i have to insert the details into MySQL table instead of inserting them into MySQL. Let's say I've all the details which are to be inserted . So, how can i send them as body to POST call and how can i invoke my post call here. can anybody tell me how to proceed. I'm not getting any idea. Thanks in advance.
I am using jsonplaceholder (http://jsonplaceholder.typicode.com/) locally. I am testing my GET and POST calls via extjs rest proxy.
I am able to read data. But when I create a model object and save it, the HTTp code for option is 204 and for POST is 200
BUT data is not stored in database of jsonplaceholder local server.
Any Idea where actual problem exists?
I have worked with json-server and this is the expected results and for your knowledge, here is a detailed explanation of HTTP Status codes Status Code Definitions.
How to query ASP.NET Web API, but with a JSON POST, not GET URL?
The JSON object would contain the same data/filters/sort/paging as ODATA query or LINQ query. Can we deserialize the JSON object into something ODATA/LINQ can understand and then use that to easily execute on the DB (SQL Server)?
We've come across from articles about LINQ Expression Trees and ODataLib ODataUriParser, but still researching.
We want to expose an advanced search web service for a few tables or views in SQL Server, and want to keep it JSON and generic so many platforms can consume it. The consumer would need to pass in the search parameters, and we could probably create a data structure to contain it all, but are trying to also see if we can leverage some query model in ODATA or LINQ.
Any way to instead of putting the OData query in the URL, put it as a POSTed JSON object instead and have it continue to query the DB and return results normally? A couple of current reasons to put in POST are 1. can handle larger size and 2. instead of the consumer learning OData query syntax, they can just popular an search param object model.
Thanks in advance.
I understand that SQL Server endpoint returns data using SOAP.
Does anyone know if they can return JSON data?
Thanks!
Native HTTP endpoints can only return SOAP messages.
However it's possible to switch off the generation of the SOAP envelope, if you specify FORMAT = NONE in the FOR SOAP section of the declaration.
You could use this to provide an HTTP wrapper to your own stored procedure(s) which JSON-ise SQL server data (see books online for a detailed description of the very specific requirements your procedure must fulfill).
You should be aware that native endpoints are deprecated in SQL 2008.
No, unfortunately they don't support JSON.