Questions tagged [rest]

24526 questions
1

votes
1

answer
1k

Views

API call from one Django site to another

I'm pretty new to Python/Django but I have set up an REST API for one website (siteA.com), and would like another website (siteB.com) to be able to call this API and show some results. For this I have added the Django REST Framework and Django Auth2 Provider to siteA. I can now call the API using...
Michael Nieuwenhuizen
1

votes
4

answer
3.5k

Views

How to use Django REST framework with a model with default value for foreign key?

Django==1.5.5 djangorestframework==2.3.8 I have a model with a Foreignkey: class Role(models.Model): name = models.CharField("Name", unique=True) def __unicode__(self): return unicode(_(self.name)) class Worker(models.Model): name = models.CharField("Name") role = models.ForeignKey(Role, default=1)...
Toff'
0

votes
1

answer
44

Views

Why are my parameters staying null after i try to send an HTTP Response to my server

I have searched for 3 days now for an answer on this topic. I have a project I'm trying to do and I got stuck at the login part. I am trying to send the parameters from my angular App to my backend java project. Here is the java login algorithm: public CouponClientFacade login(String name, String p...
EliKnaffo
0

votes
1

answer
24

Views

Disable read only fields in the response after posting the data

My model: class NewsID(models.Model): pass class News(models.Model): newsId=models.ForeignKey(NewsID,related_name = 'News', on_delete=models.CASCADE) lang_code=models.CharField(max_length=2) headline=models.CharField(max_length=100) class DefaultLanguage(models.Model): news_id = models.ForeignKey(N...
mounika kommineni
0

votes
0

answer
3

Views

django-oauth-toolkit-0.11 permission raises 401

Tech Stack:- Django1.10 + python3.6 + docker + DRF + React + Axios + Cross domain Error:- "detail": "Authentication credentials were not provided." As soon as I get my access_token I make a GET call with the same access token and every time I am getting 401 status code with the error mentioned above...
user734353
1

votes
1

answer
956

Views

Unrecognized field “_links” since the 2.0.0.RC1 of Spring Data REST

On one side, I have just update the version of spring-data-rest-webmc to the latest 2.0.0.RC1 version of my server. In this version, the json format change to an HAL format. On the other side, I have a client which use the spring-hateoas library with the 0.9.0.RELEASE version. In this client, I use...
bwilcox
1

votes
1

answer
2.5k

Views

Can Jersey convert a GET returned POJO to XML or JSON depending on the request's Accept header?

This question is for Jersey 2.x. Let's say I have a GET method. The client request contains an Accept header for either XML or JSON. Is it possible for the method to return a POJO in the representation the client requested? Currently, my GET method returns JSON using Jackson. But I don't know how...
devdanke
1

votes
1

answer
326

Views

Django + rest-framework: serialize arbitrary query

I have three classes representing different sections in my models: SectionA, SectionB, SectionC. Each of these sections have associated a set of items (class Item in my model). I would like to get a json similar to this: { "sectionA": [ { "id": 1, "picture": "car_pic1", "category": "cat1" }, { "...
Esparver
0

votes
1

answer
22

Views

API calling using CodeIgniter famework

I am getting an error when calling the rest API in postman. please solve the error. The given error is shown below. An uncaught Exception was encountered Type: Error Message: Call to a member function row() on boolean Filename: C:\xampp\htdocs\CodeIgniterRestApi\application\libraries\REST_Controller...
Stylo Test
0

votes
1

answer
21

Views

What do I use the Serializer create method for?

I am trying to implement a simple flow where the a user POSTs a secret code to an api endpoint. By doing so the user creates a foreign key relationship with another model. I achieved the desired behaviour on the serializer by overwriting the create method like so: class RegisterUserToCustomerSeriali...
Xen_mar
-1

votes
1

answer
31

Views

python calling one function from another

Im creating a serializer using python django DRF .Im creating a separate helper class and trying to override the create method. My helper class: class WorkFlowHelper: def create_levels(self,levels): for level in levels: workflow_level = WorkflowLevel() workflow_level.workflow=self, workflow_level.le...
Mohit Harshan
1

votes
2

answer
569

Views

Manually adding attribute to request body after authentication

I am developing an ASP.NET Web API 2 application. When an HTTP request is going to come in which contains user authentication credentials, before it reaches the defined route(for which I am using Attribute routing), I want to somehow add a filter so that it can authenticate the user, and upon succes...
Waqas Shah
1

votes
4

answer
53

Views

Simple PHP rest json duplicates data fields

I'm iOS developer and for finishing prototype I need simple php code which could return data from particular table as JSON. Here is a code I developed: The problem is that it duplicates data fields. Here is a result I receive: [ { "0":"1", "id":"1", "1":"Some title", "title":"Some title" } ] In data...
Sergio
1

votes
1

answer
1k

Views

sugarcrm rest api get_entry_list where with related field

I am using the sugar rest api get_entry_list to get certain notes related to a particular lead. Suppose lead x has 5 notes attached to it and 2 of those notes has test in the name field. I want to get just those 2 notes, not all 5 of them. I have tried setting the query attribute to: id = x and na...
ajon
1

votes
3

answer
5.7k

Views

What is a good way to send large data sets to a client through API requests?

A client's system will connect to our system via an API for a data pull. For now this data will be stored in a data mart, and say 50,000 records per request. I would like to know the most efficient way of delivering the payload which originates in a SQL Azure database. The API request will be a RES...
ElHaix
1

votes
1

answer
657

Views

REST Service | JSON response format

I have created a REST Web Service using RESTEasy implentation of JAX-RS. I have an Employee POJO class which is sent as response. The response is in the json format. The problem is that I am returning the List of Employees back to the caller. Below is the code. Below is the Employee POJO class @XmlA...
Manav Bhanot
1

votes
3

answer
815

Views

How can I find out why an object can't be JSON serialized? [duplicate]

This question already has an answer here: is not JSON serializable 2 answers I have a very simple use case of data that I wish to serialize to JSON, but I keep getting tripped by error TypeError: is not JSON serializable Here is the object I want to serialize - class MemberInfo: def __init__(self,...
self.
1

votes
0

answer
10

Views

Sending Multipart/mixed request with boundaries

I am trying to create a multipart-mixed request with two sections:- application/x-url-form-encoded multipart/form-data Example Request:- POST http://sample:8080/api/documents HTTP/1.1 Accept: application/json Accept-Language: en API-Version: 2 Content-Type: multipart/mixed; boundary=19D523FB Host:...
leo_roar_001
0

votes
0

answer
6

Views

How to create a SSIS package to ETL JSON from Python REST API request into MSSQL server?

I am trying to take a Python script I wrote that makes GET requests utilizing a REST API and returns data in the form of JSON and then have that data be inserted into a MSSQL server that I will have to create. This job will need to run each day at least once. I am not familiar with creating tables...
Dylan Janszen
0

votes
0

answer
4

Views

django-rest-framework: manage generateschema

The command: $ python.exe manage.py generateschema responds with just almost empty YAML: info: description: '' title: '' version: '' openapi: 3.0.0 paths: /swagger: get: operationId: swagger_list tags: - swagger servers: - url: '' Though I have quite a rest-api.... Whant am I doing wrong?
Symon
1

votes
2

answer
2.6k

Views

How to add extra parameters in tracking URL in eloqua email?

I am working on eloqua 10. I have a scenario like this, suppose i am creating a an email in eloqua and which has a tracking link on the email template. http://www.mytestsite.com/page.html?elqTrack=true Now,I would like to pass the contacts email address to be appended to the above link loke this htt...
Aju Mon
1

votes
1

answer
958

Views

How are Jersey @Consumes endpoints matched?

I am designing a RESTful endpoint to receive files. I would like to it to accept POSTing as both plain file/stream and multipart. Is there a rule how are endpoints matched by the servlet container? Would the code below work reliably, or is this implementation specific? Can I get away with WILDCARD,...
mikijov
1

votes
3

answer
2.5k

Views

Extract JSESSIONID in REST after login

I'm working on system which will allow users to create workspaces.After workspace creation user may login by providing username, password and workspace. And i need jsessionid generated after login to create connection between workspace and jsessionid. Login goes thru REST. @POST @Path("login") @Pro...
Nem
1

votes
2

answer
2.4k

Views

Right way to enable requests with method DELETE in nginx

I was writing a RESTful applicaiton in PHP and enabled DELETE, PUT requests for nginx. location / { root html; index index.php index.html index.htm; dav_methods PUT DELETE; } When I executed a REST Request with method DELETE, which I wanted to handle inside my index.php - nginx removed the html f...
Skip
1

votes
1

answer
179

Views

Defining a REST api

I was wondering what the most correct or best practice way to define a rest api would be. Lets say I have an application that deals with cars and their parts/components. Any api will always start first with the top level car. So, in defining my api should I go with: [url]/{resourceName}/{carId}/{...
tas2826
0

votes
0

answer
34

Views

How to instance 2 different object with only one HTTP request (JSON file)

I made a database with Java Spring and Hibernate. There is an responsable entity and an account entity and they are linked with OneToOne relation. Here are my code : REST controller : @RestController @RequestMapping("/test") public class test { @Autowired private final ResponsableDBRepository respo...
Flo_H99
0

votes
0

answer
2

Views

SlugField in ViewSet doesn't populare dropdown in JSON webform

I have a Django REST framework application with a course and department model. I have the following models, serializers and viewset to represent the course catalog. ## MODELS ## class Department(models.Model): """Academic Department""" name = models.CharField(max_length=30, unique=True) class Cours...
Justin Dearing
0

votes
0

answer
2

Views

explanation on HTTPS Records Query

Can anyone please explain how first set, previous set, next set, and the last set of records can be used to query HTTP rest message data. what exactly does this do? I got some information in ServiceNow website, where i am not able to understand. Can we use this instead of sysparm_limit/sysparm_offse...
halale ravi
1

votes
0

answer
9

Views

Is there a PayPal SDK that uses V2 of the REST API

I am using the Java SDK for PayPal's REST API. However, I notice that a lot of the SDK uses a version of the API that has been deprecated (V1 instead of V2). For example, the sample docs for executing a payment using the SDK use a PaymentExecution Object. As you can see from the API docs, this field...
theyuv
1

votes
1

answer
991

Views

How to use url encoded string in Firebase REST Query using startAT

In our database we have URLs that are used as FireBase keys. These keys are url encoded strings of the form: http%3A%2F%2Fblog%ZZexample%ZZcom%2F_Test_Blog_2015_06 A GET request returns empty: curl 'https://mydb.firebaseio.com/publishers/0000014d45a67fa3_4e93b3f/sites/0000014d45b0dc08_20173d1/pages....
Sam
1

votes
1

answer
3.5k

Views

spring-boot-starter-web vs spring-boot-starter-thymeleaf

I try understand how spring boot is working with html pages. I started following the guide from spring.io. This guide is showing how to work with html page and view technology Thymeleaf. It has page: Getting Started: Serving Web Content I have changed it to simple Getting Started: Serving Web Conte...
Loniks
1

votes
2

answer
1.1k

Views

In Django Rest Framework, how do handle invalid filtering parameters?

I want to limit the queryset returned by a ListAPIView, using the filtering technique described here. The question is, how do I handle invalid parameters? Raising a ValidationError only works for serializers, not within the ViewSet. I'd like to let the user know that the request was invalid, rathe...
seddonym
1

votes
1

answer
5.9k

Views

Codeigniter REST API giving unknown method?

I'm using https://github.com/chriskacerguis/codeigniter-restserver with codeigniter. I'm trying to add a resource, and enable a get method with an id. I added the Users controller which inherits the REST_Controller. I added a few methods, index_get, index_post. They both worked perfectly. I then att...
maor10
1

votes
2

answer
1.3k

Views

Modify data before validation step with django rest framework

I have a simple Model that stores the user that created it with a ForeignKey. The model has a corresponding ModelSerializer and ModelViewSet. The problem is that when the user submits a POST to create a new record, the user should be set by the backend. I tried overriding perform_create on the Model...
Luke Sapan
1

votes
1

answer
2.9k

Views

Access token from view

I am starting with django-rest-framework and I can't find the way to access the Token value from the view, is it possible? I am not using built-in token generator, I use a custom function to do it. In request's headers I give this: Authorization: 'Token kjansfd98qhr23d09823098fdj' How can I access t...
Gocht
1

votes
1

answer
24.2k

Views

Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException:

I am running one small RESTFull example but I am getting following exception, not sure why, can some one please help me why i am getting this exception? Details are below: Note: I am learning RESFFull service first time, please excuse me if any typos or silly mistakes. Customer.java: package com.tes...
Vasu
1

votes
1

answer
858

Views

Django rest framework : How to accept only json data?

I would like my Django rest framework API's to accept only Json data. So i set it in the default settings. REST_FRAMEWORK = { ... 'DEFAULT_PARSER_CLASSES': [ 'rest_framework.parsers.JSONParser', ], } but the views are still accepting the multipart form-data and x-www-form-urlencoded. If i set the Mu...
Sachin Gupta
-1

votes
2

answer
14

Views

REST endpoints names

I am having trouble naming rest endpoints for my otp service. Here I have 4 endpoints, in brackets I have given inputs SEND API (Mo. No.) - Generates OTP and send to mobile number, in response it gives TransactionId RESEND API (TransId) - Resend same OTP to mobile Number with the transactionId VERIF...
prakharjain
1

votes
1

answer
545

Views

Elixir: how to post on a rest API (redmine) with httpotion

Hello I am trying to create and issue posting to Redmine API def createIssue(issue) do value = %{"project_id" => 1, "subject" => "Example", "priority_id" => 1, "tracker_id" => 1} content = Poison.Encoder.encode(value, []) HTTPotion.post("#{url}/issues.json", [body: "issue=#{content}" , basic_auth: a...
Paolo Freuli
0

votes
0

answer
3

Views

How to connect registration html with postmapping

i v got html registration page with submit button. An i have RESTController which must post from this form @RequestBody. How can i connect them? @RestController public class RestControllerExample { @PostMapping("/registration") public void postLogin(@RequestBody User user) { logger.info(user.getEmai...
Slava Vir

View additional questions