api-design

REST API Design sending JSON data and a file to the api in same request

穿精又带淫゛_ 提交于 2019-12-23 12:04:20
问题 I am creating a REST API on top of an existing application. One of the features takes in a json data along with a file uploaded by the user. I am unsure how to send a file AND json data in the same request to the REST API? I have the json part working and I test that using curl: curl -XPOST http://localhost:8080/myapp/foo -d '{"mydata": { "name": "somename", "gender": "male" }}' //I would like to send an image (say, profile image) with the above request as well. I'm using a grails application

ActionCable usage in Rails 5 RESTful API Development?

社会主义新天地 提交于 2019-12-23 03:43:09
问题 I am trying to create a RESTful API for the first time. Sending Request(Client to Server) and Response(Server to Client) using Action Cable. How to send request from other Applications(like Android/iOS App, Web App'n or Desktop App'n) and give response to the application. I have used Action Cable in normal Web Application. Please provide me some links with guides of ActionCable usage in Rails 5 RESTful API. Thanks in Advance. 回答1: Here is the detail to use Action Cable as Restful API. Use

Naming a dictionary structure that stores keys in a predictable order?

寵の児 提交于 2019-12-22 04:06:46
问题 Note: Although my particular context is Objective-C, my question actually transcends programming language choice. Also, I tagged it as "subjective" since someone is bound to complain otherwise, but I personally think it's almost entirely objective. Also, I'm aware of this related SO question, but since this was a bigger issue, I thought it better to make this a separate question. Please don't criticize the question without reading and understanding it fully. Thanks! Most of us are familiar

Query String vs Resource Path for Filtering Criteria

强颜欢笑 提交于 2019-12-21 13:19:10
问题 Background I have 2 resources: courses and professors . A course has the following attributes: id topic semester_id year section professor_id A professor has the the following attributes: id faculty super_user first_name last_name So, you can say that a course has one professor and a professor may have many courses. If I want to get all courses or all professors I can: GET /api/courses or GET /api/professors respectively. Quandary My quandary comes when I want to get all courses that a

What are the pros and cons to api versioning methods

别等时光非礼了梦想. 提交于 2019-12-21 04:52:15
问题 I've notice in some example two ways of versioning an api. One of them is using a version in the url /api/v1/products The other is using the content type header and the accept header to mark the api version for the data send to the server Content-Type=application/vnd.company.v2+xml What are the pros and cons to this approaches ? What are some use case where you will use each approach ? 回答1: I've been used to having the version number in the URL itself (/v1/). I personally think this is a much

How “store” REST archetype isn't creating a new resource and a new URI?

浪子不回头ぞ 提交于 2019-12-21 02:34:05
问题 REST API design indicates there are four resources archetypes: document, collection, store and controller. Store do not create new resources; therefore a store never generates new URIs. An example: PUT /users/12245/favorites/boston-celtics A user added Boston Celtics to his favorites list. But how that isn't creating a new resource ? and how it isnt generating a new URI? 回答1: A store does not create a resource on its own. The user of the store creates endpoints / URIs. The contrast is between

Consuming own API for web app - Authentication process with OAuth2

陌路散爱 提交于 2019-12-20 11:51:55
问题 Overview I am currently in the process of creating an API for an image sharing app that will run on the web and sometime in the future, on mobile. I understood the logical parts of API building, but I'm still struggling to meet my own requirements for the authentication part. So, my API must be accessible to the world: those with guest access (non logged in people can upload, for example), and also to registered users. So when a registered user uploads, I obviously want the user information

Safely use containers in C++ library interface

爷,独闯天下 提交于 2019-12-20 09:38:52
问题 When designing a C++ library, I read it is bad practice to include standard library containers like std::vector in the public interface (see e.g. Implications of using std::vector in a dll exported function). What if I want to expose a function that takes or returns a list of objects? I could use a simple array, but then I would have to add a count parameter, which makes the interface more cumbersome and less safe. Also it wouldn't help much if I wanted to use a map , for example. I guess

Best practices and guidelines for designing an API [closed]

孤街浪徒 提交于 2019-12-20 07:57:00
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . What are some guidelines and best practices that I can adhere to while designing an API? At the bare minimum, I know that an API

API Endpoint Semantics

混江龙づ霸主 提交于 2019-12-18 10:14:41
问题 Is an API endpoint the 'method', like https://api.foursquare.com/v2/venues/ or the full URL including non-query-string parameters like https://api.foursquare.com/v2/venues/5104 In other words, are these two separate endpoints or considered the same endpoint? http://myapi.com/somemodel/1 http://myapi.com/somemodel/2 回答1: According to this Wikipedia article, the endpoint is a web service, defined by a WSDL file, and does nothing more than define the address or connection point to a web service.