rest

BindException thrown instead of MethodArgumentNotValidException in REST application

可紊 提交于 2021-02-17 21:44:50
问题 I have a simple Spring Rest Controller with some validation. My understanding is that validation failures would throw a MethodArgumentNotValidException. However, my code throws a BindException instead. In debug messages, I also see the app returning a null ModelAndView. Why would a Rest Controller throw BindException or return a null ModelAndView? Note: I am testing my web application using curl and making an HTTP POST curl -X POST http://localhost:8080/tasks I am intentionally omitting the

Spring JPA REST sort by nested property

五迷三道 提交于 2021-02-17 21:43:35
问题 I have entity Market and Event . Market entity has a column: @ManyToOne(fetch = FetchType.EAGER) private Event event; Next I have a repository: public interface MarketRepository extends PagingAndSortingRepository<Market, Long> { } and a projection: @Projection(name="expanded", types={Market.class}) public interface ExpandedMarket { public String getName(); public Event getEvent(); } using REST query /api/markets?projection=expanded&sort=name,asc I get successfully the list of markets with

Django - How to filter by date with Django Rest Framework?

依然范特西╮ 提交于 2021-02-17 21:35:29
问题 I have some model with a timestamp field: models.py class Event(models.Model): event_type = models.CharField( max_length=100, choices=EVENT_TYPE_CHOICES, verbose_name=_("Event Type") ) event_model = models.CharField( max_length=100, choices=EVENT_MODEL_CHOICES, verbose_name=_("Event Model") ) timestamp = models.DateTimeField(auto_now=True, verbose_name=_("Timestamp")) I'm then using Django-rest-framework to create an API endpoint for this class, with django-filter providing a filtering

Best way to return error messages on REST services?

最后都变了- 提交于 2021-02-17 21:31:03
问题 I've been looking at examples of REST API's like Netflix http://developer.netflix.com/docs/REST_API_Reference#0_59705 and Twitter and they seem to place error messages in the statusText header response instead of the responseText. We're developing an internal RESTful api and I am arguing for sending custom statusText messages and ignoring the responseText. For the scope of our app, we're returning error 400 when the user has tried doing something they aren't supposed to, and the only error

Django REST Framework: raise error when extra fields are present on POST

寵の児 提交于 2021-02-17 21:13:32
问题 When you're writing a serializer, it is trivial to specify which fields will be included (via Meta 's fields ), setting read/write permissions on them and validating them. However, I was wondering if there is an easy way to specify that only the fields that are included are to be expected and any extra keys passed in should raise an error. E.g. say, I have a serializer class ModelASerializer(serializers.ModelSerializer): class Meta: model = models.ModelA fields = ('name', 'number') Supposed

Django REST Framework: raise error when extra fields are present on POST

流过昼夜 提交于 2021-02-17 21:12:02
问题 When you're writing a serializer, it is trivial to specify which fields will be included (via Meta 's fields ), setting read/write permissions on them and validating them. However, I was wondering if there is an easy way to specify that only the fields that are included are to be expected and any extra keys passed in should raise an error. E.g. say, I have a serializer class ModelASerializer(serializers.ModelSerializer): class Meta: model = models.ModelA fields = ('name', 'number') Supposed

undefined reference to symbol '_ZN5boost6system15system_categoryEv' error

社会主义新天地 提交于 2021-02-17 20:36:07
问题 I'm new to c++ rest sdk Casablanca and using it in Codelite ide . Operating System : Arch Linux gcc version : 6.1.1 While building the code I get the following error in debug mode: /bin/sh -c '/usr/bin/make -j4 -e -f Makefile' ----------Building project:[ Casa - Debug ]---------- make[1]: Entering directory '/home/vinci/Documents/CPP_Projects_Programs/Casa' /usr/bin/g++ -c "/home/vinci/Documents/CPP_Projects_Programs/Casa/main.cpp" -g -O0 -fopenmp -std=c++14 -std=c++11 -Wall -o ./Debug/main

undefined reference to symbol '_ZN5boost6system15system_categoryEv' error

独自空忆成欢 提交于 2021-02-17 20:35:31
问题 I'm new to c++ rest sdk Casablanca and using it in Codelite ide . Operating System : Arch Linux gcc version : 6.1.1 While building the code I get the following error in debug mode: /bin/sh -c '/usr/bin/make -j4 -e -f Makefile' ----------Building project:[ Casa - Debug ]---------- make[1]: Entering directory '/home/vinci/Documents/CPP_Projects_Programs/Casa' /usr/bin/g++ -c "/home/vinci/Documents/CPP_Projects_Programs/Casa/main.cpp" -g -O0 -fopenmp -std=c++14 -std=c++11 -Wall -o ./Debug/main

undefined reference to symbol '_ZN5boost6system15system_categoryEv' error

寵の児 提交于 2021-02-17 20:35:19
问题 I'm new to c++ rest sdk Casablanca and using it in Codelite ide . Operating System : Arch Linux gcc version : 6.1.1 While building the code I get the following error in debug mode: /bin/sh -c '/usr/bin/make -j4 -e -f Makefile' ----------Building project:[ Casa - Debug ]---------- make[1]: Entering directory '/home/vinci/Documents/CPP_Projects_Programs/Casa' /usr/bin/g++ -c "/home/vinci/Documents/CPP_Projects_Programs/Casa/main.cpp" -g -O0 -fopenmp -std=c++14 -std=c++11 -Wall -o ./Debug/main

REST service: The proper way of returning exception

血红的双手。 提交于 2021-02-17 19:14:44
问题 I use Jersey API for my REST service. My question is: Is there a more elegant way of returning exceptions in a JSON form? Is it better to concern myself with creating a json object myself and attaching it to the response directly? This is a simplified example of one of the methods in the service. As you see, I use HashMap only because the method may throw an exception, in which case I need to return information about It. @Path("/admin") public class AdminService { @Context HttpServletRequest