I am developing a modx RESTful API. I would like to ask, if anyone knows how to post directly from browser to modRestController class and finally with this post I can save the information to the database.
I believe this two posts will help you:
You need to create proper REST API files&folders structure
Implement custom database logic
Call 2 in 1
Related
I'm working on a project that require API that does not exist yet (I thought I would never be in this situation... :D) - so I have decided to build my own.
I'm using MongoDB as a database, Node.js, Express.js as backend framework,and Mongoose as ODM tool.
It's very simple API, all I need is 3 get routes:
GET example/random-item
GET example/all-items
GET example/some-items/:limit/:skip?
And one more thing that I need is a way to post new items to the API:
POST example/add-item
How can I make sure, that I will be the only one, who can access this route?
I want to be te only person that fan maintain the API, users can only GET data, they cannot POST data.
How does it work in a real word, when someome is maintaining some bigger API with more routes and more data?
Kind regards,
Bartek
My question is probably very simple, or the answer on it is. I'm doing some project of mine, non-profitable, movie/show tracking type web application. I'm using TMDb API, and in node I'm using node-themoviedb wrapper. Can I, somehow pass the parameters to the wrapper to which page I want from the API. Now I know, API can through URL parameters, know which page I want, but I'm asking for this wrapper. Should I even do pagination in backend, or is it simpler doing it in frontend? Thanks!
string entityAsString = sr.ReadToEnd().ToString().Replace("{0}", Convert.ToString(root.CategoryID.value)).Replace("{1}", root.Name.value);
can i post the data like this, is there any other way to post the data to item screen please tell me.
Deepika, Have you looked at the wrapper in github? https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp
This project does all the heavy lifting interfacing with the api for you. Perhaps, even if you didn't use the project, it would explain how to post the data properly.
Also it is being maintained by Acumatica so its always current.
I have developed an application which was MVC application. It has a requirement that the application will return json data for one get request.
So I have added apicontroller and created a get method to return json data.
So far so good. but then I thought, is it really needed to add apicontroller to create just one get method.
I started exploring and googling what is the difference other than content negotiation. Got lots of answers and articles but non of them were satisfactory.
So here is the actual confusion, why can't I just create a method in the MVC controller with JsonResponse and return the json data(Which I know only is need for my requirement, but other application on different domain will consume it).
Can anyone convince me why should I use apicontroller instead of MVC JsonResponse for my requirement or should I not be using apicontroller at all.
apology if there is any mistake.
If I get it right the question is Can we use MVC action to serve json content answer is yes! Is it okay to use Json Result? answer is It depends where do you want to consume it
Say I am an in a Web Environment where I have no need for the APIs (that means I am not going to serve my data to multiple clients) If that's the scenario where only your View is going to consume data returned from your Action Method you are good to go. An Action returning a Json Result is basically an Action Result and that's what it is made for.
but If you are in a REST scenario and you need your backend to serve your data to the client de facto standard is to use an independent Web API for that.
Controllers' main responsibility should be to work as an intermediary between your View and Model and whatever service layer you want to bring inside it. on the other hand, Web APIs are data-driven there only purpose is to serve data (use them if you need them)
Web APIs are good cause they give you the flexibility of serving the data to possibly any client that might need it. That's what I would pick if I am starting from scratch but if I only need to serve data to one client Controller Action methods will be way to go.
Hope this helps.
I am tyring to retrieve the details of all User Stories for a specific project. I am using the REST URL:
https://rally1.rallydev.com/slm/webservice/1.34/hierarchicalrequirement?project={Rally_REST_URL_for_the_project}&fetch=true
I am using JAXB to unmarshal the XML response. However, the result consists of objects of type DomainObjectType and hence I cannot cast them into HierarchicalRequirementType - in fact the data pertaining to User Stories are not retrievable.
Is there any other way of doing this? I got the XML Schema from the Rally Help pages, and I do not see any way to do it other than make N+1 requests - which I would like to avoid.
Any help will be appreciated.
kind of roundabout answer - we have a beta/labs Java REST toolkit you could try here: http://developer.rallydev.com/help/java-toolkit-rally-rest-api
That might be worth a try to help move some of that along.
I have contacted Rally support for a validation of their XML Schema. Will post again once they get back to me.
--A few days later--
Thanks to everyone for their efforts.
Apparently, the XML Schema is meant for SOAP and not REST, although it can be used for REST too in some cases.
I have to modify Schema for my requirement - something I am working on now.