Replies: 39 comments
-
The basics of a REST API:
I recommend reading this article to get some basic understanding of how actions/operations should be designed. |
Beta Was this translation helpful? Give feedback.
-
It just crossed my mind that it might be a better idea to sync up the client with server with a socket. What are your thoughts and ideas so far for server pushing data to client? |
Beta Was this translation helpful? Give feedback.
-
I've never understood the mindset of so-called web developers. Their ideas seem inconsistent to me. Even many of the web standards look like some kind of flawed and ill-conceived in my opinion.
This also looks inconsistent to me. You wrap request/response data in JSON, thereby defining a new level of interaction between the client and the server, working on top of HTTP. Why do you still insist on using HTTP methods and status codes? Why not make this new protocol layer complete, and use HTTP only as a transport layer for it? |
Beta Was this translation helpful? Give feedback.
-
Please be more specific when expressing your ideas. |
Beta Was this translation helpful? Give feedback.
-
Is this really required? Why would we want to open our resources to anyone/selected ones on the net? IMO, this is asking for trouble for our primitive web server... |
Beta Was this translation helpful? Give feedback.
-
These are idustry standards. I understand if you don't see them necessary, maybe web socket is a better option for QBT, read below.
Of course. I was suggesting to use a web socket to transfer data instead of client pulling the resource every second or so.
It should be open so web app can be served on a different domain. There is no difference between the web-server you already have and a rest api supporting CORS. the only difference is how browser communicate with the server and giving access based on response headers. Server should send CORS headers in response indicating who should have accees to the resource. These configuarion should be part of WebAPI settings. |
Beta Was this translation helpful? Give feedback.
-
This is a reply to this comment
This breaks one of REST api rules. Endpoints must be stateless and they should return according to the request. They should not be mutated by sessions. PS: Again I'm not saying you should implement this but these are standards. |
Beta Was this translation helpful? Give feedback.
-
Without going into details, I want to note that our Web API should be convenient for any type of client applications, and not just for browsers. How difficult will it be to implement an iOS/Android/etc. application using this? |
Beta Was this translation helpful? Give feedback.
-
Quote from linked docs:
So the sessions are still here. The only difference is where they are stored. |
Beta Was this translation helpful? Give feedback.
-
Of course you won't be able to access the resouces with curl but web-socket is a standard protocol and its client can be implemented very easily in all platforms (iOS for example). There are other ways to push data from server to client that maybe we should explore those before. Server events is another old approach that even works with http v1 but didn't get too much attraction (php example)
Would you give me an example so I'd understand what kinda asynchronous operations are we dealing with? Update: I'm working with |
Beta Was this translation helpful? Give feedback.
-
That is good news to hear and qbt already support adding custom http headers in the Options, so the CORS policy is ultimately up for the users to decide. IMO the current unspecified default should stay as is unless there are good reasons to change.
What are the improvements by using a websocket over the current request/response model? I doubt update latency is a big factor here. Also I want to note that we have to consider implementation complexity for both sides of our client/server, while firing up a websocket is just calling a built-in API for browsers/client platforms, it is very likely on the server side that we need to either write from scratch or integrate another library (which we already have enough "fun" with the current ones..) |
Beta Was this translation helpful? Give feedback.
-
Adding only headers is not quite enough. The
I'm glad you asked and we are discussing this topic. Have a look at this article to have a better understanding of all three approaches. But in a nutshell if there is nothing for client to be notified then there won't be any wasted requests flying around on the client, the connection persists till its broken or closed. The only drawback for websockets might be it cannot serve unlimited clients at a time, but I don't think this is an issue for qbt. Read more about websocket api on MDN. At the end I understand this might add complexity to qbt but I don't believe it can be any worse than what it is. If you need more details on websocket and how we can aproach an implementation I'll be more than happy to discuss further more. |
Beta Was this translation helpful? Give feedback.
-
Thanks, I have a clearer picture now.
Since qbt web server already supports Http/1.1 persistent connection, IMO the only difference here is the model to acquire data at the client-side. To be honest, I still doesn't see advantages/use case of using a subscription model over a polling one. Most of the time, I would imagine the client to ask only the data that are visible on screen and the polling model is a natural fit. Or what kinds of use case we are talking here? |
Beta Was this translation helpful? Give feedback.
-
One advantage of permanent connection and pushing data from the server side is the ability to update data using the event-based mechanism, without the need to do expensive calculations (serialize all current data and calculate the difference between them and the previous ones). I.e. in the same way as GUI does it. |
Beta Was this translation helpful? Give feedback.
-
Working more with the API i dont know if we wanna fix some of these things... its not the best but does the job so the question is if we really wanna put much effort to fix all these little inconsistencies? |
Beta Was this translation helpful? Give feedback.
-
Agree. |
Beta Was this translation helpful? Give feedback.
-
To be honest, I can't imagine that we can apply this abstraction to all the endpoints. Maybe I just didn't think about it in detail. As for Category example above, I am confused by the use of "special" identifiers for categories. Why not use the category name as an identifier? Otherwise, we will have to maintain additional mapping in the Web API layer somehow. |
Beta Was this translation helpful? Give feedback.
-
No for any mass/batch operations we will need to provide the ids in the url and that will be separated by a delimiter by convention.
I will try to provide a more detailed post including all the endpoints that I already used in the Web UI with examples sometime soon.
The reason to use an identifier and not the name is we will be able to rename the categories. Resources should not be identified by their names but by their unique identifier (possibly a UUID)
Would you explain what's this additional mapping? |
Beta Was this translation helpful? Give feedback.
-
It is off-topic, you should create an issue on your project and share the link so we can focus on that issue. It can be solved, recently I read more about cookies and cross-origin and I might be able to help you fix it. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Feel free to give examples of queries/data. Do not forget that not all of your interlocutors are well familiar with web stuff, such as REST. It's not clear to me yet why we can't pass the entire batch as JSON. |
Beta Was this translation helpful? Give feedback.
-
@aminpaks Thanks, but this cookies issue can't be fixed without some changes in QBT. |
Beta Was this translation helpful? Give feedback.
-
It's actually not that off-topic. Are you referring to |
Beta Was this translation helpful? Give feedback.
-
Yes and no, I did not specifically refer to this method. |
Beta Was this translation helpful? Give feedback.
-
I see, so internally you guys refer to categories directly with their names. Yeah this limits categories functionality not be very flexible specially for renaming them. It's really up to you if it's a lot of work feel free to keep it like this. I personally think this should be fixed.
Sorry for my ignorance, I tend to forget to explain things in full detail. I'm gonna try to share some articles and this way we can discuss only parts that are not clear instead of writing a full api doc or spec. It might be a good idea to have a swagger-ui actually for v3, it's just simpler to maintain an open api spec. To answer to your question why can't we use request payload to do batch calls, we actually can. One approach is explained in this or this article. Pay attention how the responses return the results in an array including the status codes, that's how we would fulfill some of the requests and flag the ones that failed. |
Beta Was this translation helpful? Give feedback.
-
Try to use |
Beta Was this translation helpful? Give feedback.
-
Renaming a category is a very rare operation (if I'm not mistaken, we don't even provide it currently), so that a small inconvenience will greatly concern us. But adding an ID will cause much more problems (including compatibility problems with previous versions).
In single batch Response, IIRC, which is expected.
I'm not sure what you mean. Just omit the response entry status if it is 200 (in other words, if the status is omitted, then it is supposed to be 200)?
I don't agree. If the requests inside a batch are independent then I don't see the point to fail entire batch due to one or several failed requests (moreover, some requests can be already executed and have some effect/result). #14130 (comment)
Moreover, I didn't notice another example in your links (everywhere all batch jobs are accepted as JSON). Although in some example I saw mixing JSON with query parameters ( |
Beta Was this translation helpful? Give feedback.
-
Agree, based on what you describe I think it's gonna be a bit messy to implement updating category's name. Never mind then.
My bad I didn't explain properly what I mean by "The results should not be 200 and all is good without any specific details". What I mean is for a batch operation that will create 3 resources on the server, the response should include 3 results in an array. How the response payload is constructed is up for debate, I'm going to provide an example: [
{
"status": 200,
"errors": [],
"success": { "name": "whatever" }
},
{
"status": 400,
"errors": [
{ "message": "Invalid request, missing parameter X"}
],
"success": null
},
{
"status": 200,
"errors": [],
"success": { "name": "some other info" }
}
]
Again my bad, I think you misunderstood what I mean. I am actually saying they same thing as you. If an operation can separately process a batch request then we should not fail the whole request just because of one failure.
It's a convention. We can decide to accept everything in the request payload and be done with it. There's nothing wrong with that, it's just better to have a convention and follow it everywhere. We should design all the APIs to require a payload in the request for all operations (Create, Update, Delete) instead of query params.
Sounds good. I think we will need a RFC that we can discuss the API. I'll use the first post. |
Beta Was this translation helpful? Give feedback.
-
I want websocket api,I guess it would be better than polling |
Beta Was this translation helpful? Give feedback.
-
Considering 3 years have passed, has any progress been made on this? I thought it was abandoned. |
Beta Was this translation helpful? Give feedback.
-
Hi guys,
As I'm working with the WebAPI I'm gonna suggest the improvements here. Let's keep the discussion focused on the WebAPI only It's easier to track them.
Beta Was this translation helpful? Give feedback.
All reactions