Questions tagged [rest]

REST (Representational State Transfer) is an innovative software architecture approach tailored for distributed hypermedia systems like the vast expanse of the Internet. Its rising popularity can be attributed to its ability to effectively separate client and server, achieved through the implementation of a uniform interface that connects diverse systems together. This distinguishes it from traditional RPC architectures like SOAP, offering enhanced flexibility and integration capabilities.

Utilizing Symfony REST DTO validation and injecting it into the Model similar to a paramconverter

Is there a way to create a request filter for post actions in a JSON REST API that takes the request's body, fills the DTO, validates it, and injects it into the controller action like paramconverter? I have an ExampleDTO structured like this: class ...

I keep encountering a "map is not a function" error while working with React JS

I am attempting to retrieve and display data from a MySQL database using Spring Boot and React JS in a table format. However, I am encountering an error while trying to display the information. componentDidMount(){ const currentUser = AuthService.g ...

The issue of undefined database columns arises when attempting to transmit data from an HTML form to a MySQL database via Express

My primary objective is to develop a RestAPI using Node.js and test it in a small HTML application. With the guidance of my instructor, I successfully created the RestAPI based on an example and customized it to work with my own MySQL database. Testing ea ...

What steps can I take to limit access to my API exclusively for the Frontend?

I'm in the process of creating a gaming platform, and unfortunately, there has been an exploitation of the API. How can I establish a set of "approved domains" that are allowed to access my API? The previous misuse of the API resulted in individuals manip ...

Leveraging JSON Data for Dynamic Web Content Display

I have been attempting to parse and display the JSON data that is returned from a REST API without any success. When tested locally, the API's URL structure is as follows: http://localhost/apiurl/get-data.php It returns data in the following format ...

When making a GET request, `req.body` will consistently be found void of any

Why is my req.body always empty on a GET request in Express 4.13.3, but filled with correct data on POST requests? I couldn't find any explanation for this difference in the Express documentation. This is my current Express configuration: function o ...

Develop a client-side API utilizing various libraries

After completing the server side of an API that delivers HTML via JSON using REST through CodeIgniter, I am now exploring how to create a client-side API with JavaScript. The goal is to retrieve data from the server through the API, display it in the DOM, ...

Accessing a Collection of WordPress Posts using the JSON API

I've integrated the WordPress JSON API plugin into my website. If you're interested, you can check out the plugin here: https://wordpress.org/plugins/json-api/ My current challenge involves trying to fetch multiple posts by their respective ids using a RE ...

Guide to utilizing CURL and SAML TOKEN authentication for invoking REST APIs

Here is an example of my URL: https://<ip:port>/TestRESTServices/objects/test-folder Below is the JSON data I would like to send: { "name":"test-1", "parent-uuid":"126" } I am trying to create a folder named test-1 by making a POST request ...

Ways to retrieve information from a $$state object

Everytime I try to access $scope.packgs, it shows as a $$state object instead of the array of objects that I'm expecting. When I console log the response, it displays the correct data. What am I doing wrong? This is my controller: routerApp.controll ...

Troubleshooting: Getting 405 or 415 errors when making POST requests from Vue.js to .NET Web API 2

I'm currently struggling with POSTing data to my WEBAPI. Here is the ASP.NET WEBAPI code that I am using: [RoutePrefix("api/Test")] public class TestController : ApiController { // GET: api/Test [Route] public IEnumerable<st ...

What is the best way to send an API request from a React frontend to my Next.js backend running on localhost?

I have currently developed a create react app and I am interested in creating a next.js backend for it. I have set up an API route on the server-side which will fetch data from another API and generate a response accordingly. I do not want to fully migrate ...

Sending an HTTP post request with form data and various field controls will not be directed to a Java backend

Recently, I've started working with AngularJs and I'm facing an issue with uploading image files along with their labels through a Jax-RS post rest API. My problem is that the control in my AngularJS controller is not entering the Java post API. ...

Comparing Encrypted Passwords with Bcrypt

Encountering an issue with comparing passwords despite accurately storing the hashed password during registration. Database - MongoDB Node.js version - v18.17.0 Bcrypt version - 5.1.1 Below is my userSchema: const userSchema = new mongoose.Schema({ u ...

Managing Related Data with JSONPlaceholder and MVC 5

Attempting to present a paginated table of information about "Albums" within an MVC 5 project, collecting data from various records sourced through the JSONPlaceholder REST API: View Source Users: (10 entries) { "id": 1, "name" ...

Ways to protect your ExpressJS RESTful API from unauthorized access

Is it possible to enhance security for an expressjs RESTful API so that only a react native app and react website have access? For example, the server runs on port 8000, the react native app is on port 3000, and the website on port 5000. It’s desired th ...

Getting both the data by name and its corresponding ID in an Express route parameter using Mongoose

Locating data using ID as a route parameter can be done like this The URL would look something like: http://localhost:8000/products/60d1789867bc6624403ade6e // Fetching a single product router.get("/:id", async (req, res, next) => { const id = req.para ...

I am unable to send back my JSON object

I seem to be having trouble returning a JSON object as all I get is an undefined variable. The code below is supposed to fetch a JSON element from an API. It appears to work within the success: function, but when attempting to use that data elsewhere, it ...

How can I easily send JSON using PhpStorm/WebStorm REST client?

Within the PhpStorm / WebStorm version of 2017, there exists a REST client that allows us to send requests and analyze responses. Typically, when I send a POST request using the easy form in the UI to create request parameters, the parameters are formatte ...

Guide on linking AngularJS user interface with Python server via RESTful API?

Can someone please explain the process of connecting two parts? Specifically, I am using Angular CLI for the front-end and Python for the logic. My goal is to send text responses from the front-end to my Python back-end and receive a response in return. ...

Create a Python function that takes a list as input, iterates through each element, converts it to

When working with a Python list that requires double quotes around the strings in order to pass it to an API as a list of double quote strings, I encountered an issue. The data needed by the API: data = { "styles" : styleList } It worked when I manu ...

403 Error Code - Access Denied when trying to access Cowin Setu APIs

While attempting to create a covid vaccine alert using the Cowin Setu API (India) in nodejs, I encountered a strange issue. Every time I send a get request, I receive a 403 response code from cloudfront stating 'Request Blocked', although it works fine fro ...

Accessing HP ALM with REST and JavaScript on a local server: A step-by-step guide

I am trying to access ALM using locally written JavaScript in the browser (IE11, Firefox) through the REST API, but I am unable to login. Below is the code snippet where I am attempting to request the LWSSO cookie with jQuery: var auth = btoa(USER+":"+PAS ...

A guide on representing nested JSON documents in a Java class

JSON consists of a formula along with the values of its parameters. For instance, the sum of a+b is: { formula: "a+b", values: {"a": 3, "b": 5} } Each formula in JSON requires a specific set of values. I aim to develop a Java class that comprises two fie ...

Stopping unauthorized users from manipulating REST URLs

I am currently exploring methods to prevent an exploit where a user manipulates the URL, specifically in a GET request scenario. The following code represents a route on my Express router that processes incoming requests for a certain collection "A" and re ...

Looking for CakePHP error views for handling JSON and XML responses?

I am currently in the process of developing a REST API using CakePHP. Essentially, when I send requests to endpoints like add.json, the input data is processed and a JSON response is returned. Similarly, if I send it to add.xml, an XML response is generate ...

What is the proper way to provide JSON input for a PUT JAX-RS API that accepts data of type Map<Person, Person>?

I am working on a JAX-RS REST endpoint of PUT type where I need to pass a Map to the API. @PUT @Path("/some/path") @Consumes({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType ...

Utilizing Next.js to create a Higher Order Component (HOC) for fetching data from a REST API using Typescript is proving to be a challenge, as the

In my withUser.tsx file, I have implemented a higher order component that wraps authenticated pages. This HOC ensures that only users with a specified user role have access to the intended pages. import axios, { AxiosError } from "axios"; import ...

A PHP framework designed for creating RESTful CRUD operations

I am a big fan of using SailsJS () for my projects. One of the reasons I like it so much is because it automatically creates a RESTful CRUD API. However, when working with small clients, I often find myself operating in a different environment such as Apac ...

Updating a Record in Embe Data: A Step-by-Step Guide

I have retrieved a record of my 'item' model using the following code: store.find('item', 412).then(function(item){ ... }); This is how the model looks like: item :{ title: "mySuperItem", price: "45", comments: [ 2342 ...

Implement SSL for securing the REST API connection

My current setup involves running an express js application on an aws ec2 instance to act as a REST API for my application. I am now considering adding SSL certification for my expressjs API, but I'm not sure of the best approach. 1)Should I acquire a dom ...

Looking for a superior option to Jersey/Jackson for constructing JSON REST APIs?

In my quest to develop the server side of a JSON-REST API, I have been experimenting with Jersey and its JSON-POJO mapping feature. However, even testing the most basic use-case has led me to seek help on various platforms and engage in extensive research. ...

Using Angular to make an HTTP POST request to fetch data

My trusty .net backpack has been working flawlessly. However, I encountered an issue when trying to connect it with the Angular front end. All backend requests are post requests and require passing an ApiKey in the body of each request. Interestingly, ever ...

Best practice for setting response status and JSON content in a REST API built using nodejs and express

Exploring the world of Nodejs and express through creating a small rest API has led me to ponder on the best practices for setting the code status and response data. How should this be done effectively? To illustrate, let's delve into some code (I will om ...

The Angular application is not able to initiate the POST request

I have developed a database to store game data. Through testing, I have found that adding a "team" to a "game" functions correctly. However, my Angular application is not successfully triggering the database. I have verified that the database operation wo ...

The AJAX request to the REST service is failing to trigger the success function in the AJAX call

Struggling with some issues related to AJAX, specifically when calling a Java REST server that I've developed. While I am relatively new to AJAX, I have put in quite a bit of effort searching for solutions. The problem arises when making a call from a test ...

404 Error: Enhancing RESTFul Service through Ajax

Upon making a RESTful service call using ajax : var request = $.ajax({type: "GET", type : "GET", url : "/services/equipment/searchEquipments?pId="+id, cache : false }); The java method within the service is defined as : @GET @P ...

Retrieving the XML data instead of JSON from a RESTful API

I have been practicing with the REST API to enhance my skills in Groovy-REST. Currently, I am able to extract specific JSON data from the REST response using SOAP UI 5.0 and generate a simple output from it. Interestingly, SOAP UI also provides an XML ver ...

Spring does not perform validation on JSON requests

Whenever I make the following request: "Person": { "name": 5 } The request will fail as it is a bad request since 5 is not a string. It displays: Person{name='5'}. Similarly, no error occurs when null is sent. The annot ...

Angular controller is failing to receive the dynamic JSON response from the RestAPI

Currently, I am working with JSON data retrieved from a REST API. I have successfully set up an alert that displays the JSON results within an $http.get function. Using a sample URL that contains test JSON data works perfectly fine and I receive the alert ...

Encountered CORS error when attempting to access the dynamic menu API after logging

Currently, I am working on an Angular 6 and Codeigniter project. In this project, the slider and navigation menu bar are being fetched dynamically through a REST API. Everything runs smoothly until the login process, where a CORS error is encountered. htt ...

Exploring the process of fetching a JSON object using the POST method from a client

My task involves sending a JSON object from the client to the server via a POST request. The JSON data is hardcoded on the client side. Here's a snippet of my server program (test.java) which is purely for learning purposes, so I need a clear explanation.. ...

Maximizing PUT Methods in HTTP RESTful Services

I've been playing around with my routes file and I'm looking to switch up the method being called (delete instead of update). Code Snippets: # User management API GET /users @controllers.Users.findUsers POST /user ...

Implementing JavaScript: Grouping JSON Response by Date and Category in a Table

The API response provided below contains sample data. {"success":true,"transaction":[{"_id":"58efd5717ddda769f26793fc","transId":"Exp/04-17/17","trpId":"Trav/dfsd/04-17/12","tripId":"58efd4dc7ddda769f26793f8","userId":"58ac19eaec1e7e4628be6f01","expenseHe ...

Perform an ajax POST call to interact with a RESTful API

After completing a tutorial, I successfully created a PHP Slim framework based API that allows for user registration and login with authentication: URL /register Method POST Params name, email, password The '/register' call does not requi ...

What is the best way to format the json response in order for ActiveResource to create a DateTime object from a date?

I am facing an issue with a question object that includes a created_at attribute. Whenever I retrieve a question from the REST service, it returns the created_at value as a date string, however, ActiveResource does not automatically convert this to DateTim ...

What is the best way to distinguish my REST API from my Express web application?

Currently, my Express application is serving a front-end web application. Can someone provide guidance on how to set up an API server with /api as the root endpoint? I'm looking to separate the API functionality from the main application. ...

Is there a way to detect modifications in a JSON API using Django or Android?

I've integrated djangorestframework for my api and am currently developing an Android App that interacts with the api by fetching and posting data. I'm interested in finding a way to detect changes in json data from the api. For example, in a chat applic ...

No data returned in AJAX response while trying to connect to a RESTful service

After creating a WCF REST service that returns a JSON response like {"Id":10,"Name":"Peter"}, I noticed that when trying to access it using the provided HTML5 code snippet, the status returned is always 0. Can anyone help me figure out what might be caus ...

REST, hypertext, and clients other than web browsers

I'm struggling to understand how a REST API can be both hypertext driven, as explained in this article, and still be machine readable. Let's say I create an API where one endpoint lists the contents of a collection. GET /api/companies/ When the server re ...

Changing Serializer Fields on the Fly in Django Rest Framework

I am attempting to utilize the Advanced serializer method outlined in the Django Rest Framework documentation. in order to dynamically modify a serializer field. Below is my customized serializer class: class FilmSerializer(serializers.ModelSerializer): ...

Validating PUT/PATCH requests in Laravel 5.2's REST controller

I'm encountering an issue with Laravel that is resulting in a 405 MethodNotAllowedHttpException error. I've been attempting to implement validation for update requests in my resource PointController, but it seems that the validation rules defined in the @u ...

Struggling to implement SOAP web service in AngularJS

I'm working on consuming a webservice using the Get method in AngularJS. In my controller, I've used $http to write the code. However, I'm not receiving any response and I'm unsure if the URL is being hit or not. Any corrections or su ...

Issue encountered: [object Object] is being displayed upon attempting to submit my username and password through a REST service in Angular

My code was written in Angular CLI using the Sublime text editor and Node.js. The login component can be found in logincomponent.ts file. import { Component, OnInit } from '@angular/core'; import { FormsModule, NgForm } from '@angular/forms ...

Utilize Javascript to extract and showcase JSON data fetched from a RESTful API

I'm attempting to use JavaScript to pull JSON data from a REST API and display it on a webpage. The REST call is functioning correctly in the Firefox console. function gethosts() { var xhttp = new XMLHttpRequest(); xhttp.open("GET", "https://10.10.1 ...

Issue: ENOENT encountered with __dirname usage

When building my website using Express, I encountered an issue with my code in server.js: app.use(express.static('public')); app.get('/add', function (req, res) { res.sendFile(__dirname + "/" + "add.htm");}) The structure of my projec ...

The request to send JSON POST to REST encountered a 400 Bad Request

I've encountered an issue while sending a POST request from JQuery with some data. Unfortunately, when I try to execute it through my JavaScript code, I receive a 400 Bad Request error and the REST service fails to fire. Out of curiosity, I decided to tes ...

Generate fake data for all possible combinations using JSON faker

In my current project, I am in need of creating test data for a JSON schema. I came across this fantastic github resource that has been incredibly helpful: https://www.npmjs.com/package/json-schema-faker#overview Now, how can we expand it to generate all ...

Changing a rest api POST request from JSON to form-data in Golang using the Gofiber framework

My current code successfully handles JSON in the body of a POST request, but I am now looking to switch to using form-data instead. This is my existing code: func Signin(c *fiber.Ctx) error { var data map[string]string if err := c.BodyParser(& ...

Could Angular2's Http Get method exclusively handle Json data?

mma-api.service.ts getAthletes() { return this.http.get('http://mma-data-api.mma.com/api/v3/athletes') .map(res => res.json()); } athlete.component.ts data: string; constructor(private mmaApiService: MmaApiService) { } click ...

The Axios request will be caught in the catch block if it encounters a response status code between 400 and 500

When the server sends a status code between 400 and 500, Axios will skip the `.then()` block and go directly to the `catch` block. However, if the server sends a status code in the range of 200, Axios will accept it. This code snippet represents the client ...

Retrieving information from a repository through a Rest API

Whenever I attempt to retrieve my data from the repository and log it in the console, the array seems to be empty. Here is a snapshot of the data repo: https://i.stack.imgur.com/ftCBm.png Here is the code snippet from server.js: import express from &apos ...

Launching a Phonegap app using Node.js and Express framework

My goal is to transform my current webapp into a mobile app. The existing setup consists of a nodejs-express REST API server with an HTML/JS client. I aim to utilize the API from the REST server and replace the client with a phonegap/cordova based mobile ...

Uncaught TypeError: path.resolve was expected to be a function in Node.js

As a newbie in Node.js, I am currently following a tutorial. Although I have written the syntax correctly, I keep encountering a TypeError on path.revole(). I have also implemented the use of async/await. My intention was to send a POST request to the se ...

Retrieving values from Restful webservices has never been easier than now

Currently, I am working on a small project that involves retrieving a list of values from my webservice: @GET @Path("/string") @Produces({"application/xml", "application/json"}) public List<String> test2() { List<String> list = new ArrayLi ...

A guide to accessing REST services in AngularJS using basic authentication

I currently have a REST service up and running on my server. Using Chrome Postman, I am able to access this service with Basic Authentication. However, I now want to build a user interface in AngularJS to display the data received from the REST service. T ...

Encountering an issue while attempting to make an API GET request using JSON and Python

Encountering an issue with my API get request using JSON RESTful services and Python3. Any assistance would be greatly appreciated. The API instructions I am following can be found on this website . I have the CVE number already, as it's included in the ...

Encountered an unforeseen issue: Unexpected character : within jQuery Ajax

After successfully setting up a REST web service in Java that delivers data in "application/json" format, I encountered an issue while attempting to access the REST data from my Windows machine using jQuery $.ajax. The web service is hosted on a separate L ...

Enhancing Security Measures for REST APIs

My goal is to create a unified JSON REST API that serves both my javascript web application and external developers. For my web app, I plan to implement user authentication using username/password to access private resources. For external developers acces ...

Exploring the distinctions between Node Express Router's /users/:id and /users/login routes

I am working on developing a RESTful API with endpoints like /users/:id for accessing user information and /users/login for logging in using credentials. How can I ensure that /users/:id is only accessible when :id is a number? Is this method appropriate f ...

transmitting data in JSON format through an HTTP URL

I have successfully implemented data transmission from my Android app to a REST Service using asp.net web api. The URLs I am sending, such as , are being processed in the web.api. Now, in the Android client, I am using GSON to convert a complex object in ...

Issue with AngularJS: Unable to receive response from REST API call

I'm currently working on developing a basic login form using AngularJS and a RESTful web service. While I've been able to successfully call the RESTful web service, I am struggling to retrieve the response. 1) Login Form: <div class="col-md- ...

PrismaClientValidationError: The `prisma.user.create()` method was called with incorrect parameters:

I am currently in the process of developing an API using Next.js and Prisma. Within this project, I have defined two models - one for users and another for profiles. My goal is to create a new user along with their profile by fetching data from req.body th ...

Guide to passing JSON Data as a response in Vue.js version 2

Currently working on a Vue.js website that interacts with an API (route -> /api/**). However, I am struggling to figure out the process of sending JSON responses. Is there a similar method like res.json() in Vue.js as express.js has? ...

Best practices for managing login authentication using MongoDB in a RESTful API

I'm currently figuring out how to verify if the values align with the MongoDB data. In my approach, I'm utilizing the PUT method along with attempting to utilize findOneAndUpdate to validate the values. <script> const logindetails = new Vu ...