Questions tagged [rest]

35408 questions
1

votes
1

answer
338

Views

Conditions on django filter backend in django rest framework?

I am using Django filter backend on few fields which is working very good. But i want to filter fields when i get specific condition Like if user_type is basic get filter query otherwise get all objects from model. Mine code for filters is here: http_method_names = ['get'] serializer_class = SearchS...
Salman Ahmed
1

votes
2

answer
2.3k

Views

How to add parameters to a GET request in node.js?

I am trying to access the different information from the following api:https://api.coinnest.co.kr/doc/public.html and stumped in trying to get data for all the different parameters for the /api/pub/ticker request Here is the code I have written so far, but i cant seem to get any different info for d...
WasabiCannon
0

votes
3

answer
21

Views

api status code for post request that has failed

I have an post api call that currently creates an appointment in my booking system. If the api call sends the appointment request and the api can successfully create an appoinment the api returns a 201 created status code. Currently if the appointment request is not created (due to various things su...
JimmyShoe
1

votes
2

answer
1.2k

Views

RESTful POST Response

I have an extremely simple RESTful service that receives some form data via POST, it's purpose of which is to simply retain the body of text (with a unique id) in cloud storage (Amazon S3, Azure Blob Storage, etc.) as a file... So, question is.. if everything is good, and i return a 200 response to...
m1nkeh
1

votes
2

answer
1.2k

Views

DRF Object of type 'User' is not JSON serializable

I'm trying to return the details of the current logged in user in the following way: from .serializers import UserSerializer class UserDetailsView(RetrieveAPIView):...
Ishan Khare
1

votes
1

answer
684

Views

Consuming RESTful API and converting to Dataframe in Apache Spark

I am trying to convert output of url directly from RESTful api to Dataframe conversion in following way: package trials import org.apache.spark.sql.SparkSession import org.json4s.jackson.JsonMethods.parse import scala.io.Source.fromURL object DEF { implicit val formats = org.json4s.DefaultFormats ca...
Utkarsh Saraf
1

votes
3

answer
882

Views

Django-filters: multiple IDs in a single query string

Using django-filters, I see various solutions for how to submit multiple arguments of the same type in a single query string, for example for multiple IDs. They all suggest using a separate field that contains a comma-separated list of values, e.g.: http://example.com/api/cities?ids=1,2,3 Is there a...
mart1n
1

votes
2

answer
633

Views

RESTful API: Delete Entity - What should I return as result?

I am implementing a RESTful API and an endpoint of one controller is Delete. Delete does two actions depending of the entity to be removed: it updates the entity or it deletes the entity from the database. If delete updates the entity I would send the HttpStatus 200 and the updated entity. But if th...
user9923760
1

votes
1

answer
189

Views

filterset lookups for annotated fields

i have a problem to create a filterset for one of my ModelViewSets to provide filter functionality (incl. all allowed lookups e.g. in, gt, lt, ...) for annotated fields in my api. My Code looks as following: import rest_framework_filters as filters from django_filters.rest_framework import DjangoFil...
Smie85
1

votes
2

answer
307

Views

Django Rest Framework DELETE returns no content in the body

I am using Django Rest Framework and I am making a DELETE request. As opposed to POST, PUT, PATCH, which all return the state of the object post creation/modification, delete does not return anything in the body (just the 204 code). Having this information would be helpful when trying to tie respon...
Andrei Cioara
1

votes
1

answer
215

Views

Django rest-auth Token authentication

I'm trying to use axios to get information from the /rest-auth/user/ page. This is my function: export const fetchUser = () => { const token = localStorage.getItem('token'); return dispatch => { dispatch(fetchUserPending()); axios.get('http://localhost:8000/api/v1/rest-auth/user/', {headers: { 'auth...
peter176
1

votes
2

answer
248

Views

Location for Django Rest framework exception handler

The DRF Docs say that once an exception handler is set up, it needs to be defined in the settings.py as follows: REST_FRAMEWORK = { 'EXCEPTION_HANDLER': 'my_project.my_app.utils.custom_exception_handler' } My Django project layout is like this: backend settings.py connectivity_service utils Custom40...
Amistad
1

votes
3

answer
720

Views

Filtering on action decorator - Django Rest Framework

I am trying to filter data using a decorator action on Django Rest Framework, it works perfect if I use the global queryset (get_queryset() function) but I need to use it in a separate function. I am using django-filter to perform it. This is the code. My view: class ShippingAPI(viewsets.ModelViewSe...
Jeremias Enriquez
1

votes
1

answer
576

Views

Spring boot 2.0.3.RELEASE, Spring data rest, application error, failed to start

Unable to start spring boot application. Repository and its associated domain import com.vircosolutions.mobileapi.domain.Awards; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(exported...
Rana Rashid
1

votes
2

answer
76

Views

Defining an 'HttpClient' singleton via StructureMap causes an error about 'HttpMessageHandler' being not configured in runtime

Trying to define an HttpClient singleton in StructureMap ala: For().Singleton().UseIfNone(); This results in the following error in runtime (upon dependency injection): StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type...
XDS
0

votes
0

answer
5

Views

How to format XML in Post body for as asp.net WebAPI POST route

I Have an asp.net WebAPI RESTful service, where I have a POST endpoint for GPS positions. The server controller has the following route.. public HttpResponseMessage PostGpsPositions(GpsPositionsModel positions) The body classes are as follows public class GpsPositionsModel { [Required] public int S...
peterc
1

votes
3

answer
223

Views

Spring default consumes and produces

I'm writing a servlet that will use a bunch of RestControllers to provide functionality. All of that will use JSON almost exclusively, so I would like a compact way to say: Unless specified otherwise, consume and produce MediaType.APPLICATION_JSON_VALUE for everything. I thought I found a nice solut...
Senshi
1

votes
1

answer
51

Views

Spring MVC - Rest API where is the best place for put entity together

Where is the best place for setting parent entity? In the other word, where is the best place to put entity together? In the controller, finding parent entity and setting to child then saving? @RestController public class SomeController{ @Autowired private SomeService someService; @PostMapping('/par...
mnesimi
1

votes
3

answer
41

Views

Status code for “resource will never be available in this case”

I have a REST API dealing with invoices. Now each invoice has a special 'fee list' after it gets financed. Although not all are meant to be financed. I have an endpoint which provides information about this fee list for each invoice. So if an invoice has been financed, it returns 200, if invoice has...
1

votes
1

answer
69

Views

Does sprint security JWT implementation deal with alg:none attack? [closed]

JWT implementations might be exposed to different attacks, one of them is the 'alg:none' attack (see more details here). I'm using 'spring-security-jwt' dependency in my pom.xml file, and was not able to find out whether this implementation deals with the 'alg:none' attack. Is this attack mitigated...
omer
1

votes
1

answer
40

Views

Is it good practice to directly call REST endpoint (method) from another REST endpoint of same controller?

I have one Spring REST controller class which has multiple endpoints. Is it good practice to directly call endpoint method from another endpoint? I have googled it but did not find any answer to what is the good practice to handle this. @RestController public class DataContoller { @GetMapping('/data...
Ganesh Pathak
1

votes
4

answer
103

Views

RESTful API endpoint naming

I'm working on a asp.net core 2.2 backend exposing a RESTful API. The current implementation works fine (additional code removed for clarity): namespace Sppd.TeamTuner.Controllers { [Authorize] [ApiController] [Route('[controller]')] public class UsersController : ControllerBase { private readonly I...
Philippe
1

votes
1

answer
52

Views

Django all auth: How to override the confirmation email url

What I want to do is to override confirmation email url in templates/account/email/email_confirmation_message.txt. I want to change this part To confirm this is correct, go to {{ activate_url }} to something like http://localhost:8080/confirm_email/{{ key }} However, I couldn't figure out where {{...
Ooto
1

votes
1

answer
25

Views

Django Rest Framework: pass user from view to serializer

I have such view for user change password: class ChangePasswordView(generics.UpdateAPIView): serializer_class = ChangePasswordSerializer permission_classes = [IsAuthenticated] def put(self, request, *args, **kwargs): data = request.data.copy() data['user'] = self.request.user serializer = self.get_s...
PotatoBox
0

votes
0

answer
13

Views

Spring Data Rest with url of format /foo/{id}/bar

To conform to our internal standards, we have URLs that take the format /RESOURCE/{id}/COMPONENT trying to do something like @RestResource(path = '/RESOURCE/{id}/COMPONENT') public Optional findById(long id); doesn't work (it does accept requests at /RESOURCE/{ID} though). Is there a way to make thi...
Don Hosek
0

votes
0

answer
3

Views

How can I capture Memberpress user info after signup

I'm currently working on a website where users can purchase subscriptions using memberpress, I want to capture the user data after the signup process is completed and the payment transaction is also completed as well. If I add the member through dashboard manually I'm able to catch the user info as...
RBD
1

votes
3

answer
1.9k

Views

Sending a File is better or a Output Stream

In my project we are saving some files. When a file is requested, I fetch the file from the HBase table and then send it to the browser. Data is saved in Bytes in HBase. So when I fetch the file I am getting it in Bytes. Now I have to convert these Bytes into either File object or in Output Stream....
JHS
0

votes
0

answer
11

Views

Perl REST::Client - Garbage data in response

I'm having issues getting a valid response from Perl REST::Client against Red Hat Satellite REST API. I'm getting the following encoded response: $VAR1 = '���j�0��~ �g9�� ���#�9�`dIm�m�-���uJ �����f4U�@▒�� ���F��xګ X�;�\'r�...
Mose
1

votes
3

answer
1.2k

Views

Windows Azure Services status from code

I'm working on a application which will need to know the status of Window Azure services, not my applications(i.e.: SQL Databases, Storage, Access Control 2.0, etc). I'm aware that Windows azure has a REST API, but I didn't found anything about services health or status.
0

votes
0

answer
17

Views

My angular can't get the value from html page

I have an angular function to call me rest service but it can't get the value from the html file. when i press submit the $scope.productForm is, although i still have value in my html page. Main.js $scope.products = []; $scope.productForm = { ID:1, Name:'', Description:'', URL:'' }; _refreshProductD...
Trung Đặng
0

votes
3

answer
456

Views

Registered URLs in a router not working

I am attempting to have several views in a router that is used in a url, and the urls don't seem to work at all. I followed the instructions on http://www.django-rest-framework.org/api-guide/routers/, but my code doesn't appear to work. My intention is to be able to access the views through these ur...
Jack Cole
0

votes
0

answer
5

Views

cannot import name 'URLPatternsTestCase' from 'rest_framework.test' , can anybody please tell me how to fix this error

cannot import name 'URLPatternsTestCase' from 'rest_framework.test' from django.conf.urls import include, url from rest_framework.test import APITestCase, URLPatternsTestCase from readEstateApi import views from django.core.urlresolvers import reverse class AccountTests(APITestCase, URLPatternsTestC...
Raja Paul
1

votes
3

answer
603

Views

Is it a good restful URL design to avoid using DELETE and PUT?

I read an example of restful service, it only uses two HTTP method: get post. for example, there is a task list at the server. To design the restful URL, we can use: www.example.com/task GET. return all the task list. www.example.com/task/id GET. return the specific task. www.example.com/task/c...
Jimmy
1

votes
3

answer
3.7k

Views

Delete File in SharePoint folder using C#

I am using SharePoint ExcelService to manipulate an excel file and then save it to the Shared Documents folder using ExcelService.SaveWorkbookCopy() Now I want to delete those files I saved earlier. What is the best way to achieve this using C# in a Asp.Net MVC Application? I tried it using the RES...
katho2404
1

votes
4

answer
1.4k

Views

Create Octopus machine via REST API (PowerShell)

I’m trying to create a machine via the REST API, calling it through PowerShell. According to the documentation, only the name and thumbprint of the machine are needed to create a machine. But everything I try leads to either 405 or 500 errors: $newMachine = @{Name='machineName';Thumbprint='asdvbls...
ShaneC
1

votes
1

answer
4.2k

Views

How do I render a new .jsp file in the browser using Jersey for java?

My site goes to a login page that I want to redirect to another page when the user logs in. I have a 'POST' method that sends the 'username' and 'password' to the server and the server checks if the username and password exist. Here is my method @POST @Path('logIn') public void signIn(@PathParam('p...
theGuy05
0

votes
0

answer
21

Views

Reduce number of queries made to render list of items with same in-line editable field

While rendering a table of items, if the value for field X is not defined, it is rendered as a select element. Django makes a query for each select element and these can add up and cause delays in large tables. What is the best way to reduce the number of queries? views.py from rest_framework impor...
silverstripes
1

votes
1

answer
221

Views

In Symfony2 what is the best way to use a multi word name and get a good RESTful url

I'm using the FOSRestBundle to build my symfony2 API. I have entities called things like SupportRequestTemplate, which I would like to see in the API end point but when I create the Actions with names like getSupportRequestTemplateAction(Request $request, $id) {} FOSRest treats each camel case word...
mike
1

votes
1

answer
2.2k

Views

How to handle Unicode Character in REST Api built using Spring and JAX-RS…?

My API is developed using JAX-RS and Spring framework. I am calling another API which returns a string containing special character like copyright symbol, dollar sign, euro symbol. I am assigning the same value to one field in API and sending that response. When i test my API in SOAP-UI or PostMan t...
Raghu
1

votes
1

answer
709

Views

check_object_permissions with CreateAPIView

CommentCreate is a CreateAPIView used to post comments on another 'report' model. I need to block anyone who is not the author of the report, or who is not in an assigned group of people who are allowed to post a comment, from using this endpoint to create comments. class CommentCreate(generics.Crea...
denvaar

View additional questions