FAQ Database Discussion Community


Link to another resource in a REST API: by its ID, or by its URL?

json,api,rest,api-design,hateoas
I am creating some APIs using apiary, so the language used is JSON. Let's assume I need to represent this resource: { "id" : 9, "name" : "test", "customer_id" : 12, "user_id" : 1, "store_id" : 3, "notes" : "Lorem ipsum example long text" } Is it correct to refer...

What is the GSON disableHtmlEscaping equivalent in JacksonJsonProvider

java,rest,jackson,gson,hateoas
I am trying to convert an URL e.g. https://api.test.com/cusomter?customer_id=1&customer_type=A but during serialization its getting converted into https://api.test.com/customer?customer_id\u003d1\u0026customer_type\u003dA I know that in GSON there is disableHtmlEscaping option to escape html safe conversion of = and & characters. Can you please let know the equivalaent option in JacksonJsonProvider....

Can anyone provide a good explanation of CURIEs and how to use them?

json,api,rest,hateoas,hal-json
I've seen CURIEs described in the HAL specification. At first glance, it looks like a way to provide templating for URIs. However, I also see it prominently mentioned that it can be used to access documentation on a rel. Which one is it? Is it simply a templating mechanism? Does...

Single Page Application and RESTful API

angularjs,rest,single-page-application,hateoas
A real RESTful API leverages hypermedia so that clients rely only on dynamic hypermedia provided by server to navigate through the application (the concept known as HATEOAS) This concept is easily applicable to web applications but how do you apply it to Single Page Application as SPAs normally manage their...

How to correctly use HAL (Hypermedia Application Language) _embedded?

api,rest,hateoas
I am building a REST API that exposes information about online courses to users. Here is the general structure of a course: Course > Units > Lessons > Activities I'm trying to make my JSON response structure HAL compliant, but i'm unsure if i'm doing it correctly. Which of the...

Suggesting an action to consumer in HATEOAS

web-services,rest,hateoas
I'm working on a web service API using the HATEOAS REST representation. My client can create an item (e.g. a stub of a blogpost): POST /item 204 Created Content-Type: application/vnd.foo.item+json { "id": 42, "title": "Lorem Ipsum", "status": "STUB", "body": "Very long text." "_links": { "self": { "href": "/item/42" }, "activate":...

Play! Framework REST with Hypermedia (HAL+JSON)

rest,playframework,playframework-2.3,hateoas
Is there any plugin for Play! Framework (either Java or Scala) that supports easy creation of Resources that provide hypermedia metadata along with the normal JSON entity? Something similar to Spring Data Rest / Hateoas, that enables easy link creation for json entities. I cant find any concrete examples...

HATEOAS Link using UriBuilder

java,rest,jax-rs,hateoas
I have a REST service defined as below: @Path("/v1/employee/") EmployeeService { @Path("/designation/") public void listDesignation() { } } My goal is to generate the relative URL "v1/employee/designation/". If I use UriBuilder.fromResource(EmployeeService.class), it gives me "/v1/employee/" And if i use UriBuilder.fromMethod(EmployeeService.class, "listDesignation"), it gives me "/designation" Does anyone know how I...

Concurrency in a REST api

api,rest,concurrency,hateoas
Context I'm creating a basic REST API -I don't really care about the purpose, it's just an example- where I have a cart containing: A list of items corresponding to different products. A status: either TIMEOUT, PURCHASED. A cart has a limited period of validity. A link for the payment:...

AngularJS Spring sort field names

angularjs,spring,model-view-controller,data,hateoas
I'm developing an application using AngularJS for the front-end part and Spring for the back-end. I have mainly two entity classes : @Entity public class Project implements Serializable { private static final long serialVersionUID = 1L; /** * idProject */ @Id @GeneratedValue(strategy=AUTO, generator="PROJECT_SEQ") private Integer idProject; /** * name */...

CQRS and REST HATEOAS mismatch

rest,domain-driven-design,cqrs,hateoas
Suppose you have a model Foo. One business case is to simply create an instance of Foo, so there is a corresponding CreateFooCommand in my model, triggered by invoking a POST request to a given REST endpoint. There are of course other Commands too. But now, there is a ViewModel,...

How to configure Spring HATEOAS behind proxy?

spring,rest,spring-data-rest,hateoas,spring-hateoas
I have Spring Data Rest with Hateoas as my backed. It is behind a proxy. Backend url: backend.com Proxy url: proxy.com When I query proxy url, e.g. http://proxy.com/items/1, I get a response with href links with domain backend.com. I need the domain to be proxy.com....

Restangular no BaseUrl when do PUT

angularjs,restangular,hateoas
i'm using Restangular and trying to PUT some data but it seems to lose the BaseUrl. In the config function i define the BaseUrl for Restangular and others Restangular fields. Constants.restangularBaseUrl is http://192.168.1.100/api/ RestangularProvider.setBaseUrl(Constants.restangularBaseUrl) .setRestangularFields({ selfLink: '_links.self.href', id: '_id', etag: '_etag' }) .addResponseInterceptor(function(data, operation, what, url, response, deferred){ if (operation...

How to implement deep linking client on top of HATEOAS server?

single-page-application,pushstate,hateoas
There's a similar question on SO, but it's not phrased well and it lacks details. So I'm trying to write a better question. I'm interested in how to implement HATEOAS with a single page application (SPA) that is using pushState. I want to preserve deep linking so that users...