I have written a basic simple API of students data and added few validations using Hibernate validator but everytime its returning 0 errors. Here’s the code: pom.xml student.java Controller.java I am testing it using postman,My request body: In every request,even if name is empty Its returning 0 errors. Can someone help? Thanks in advance. Answer you need to add starter
Tag: api
Cannot invoke findByEmail because “this.userRepository” is null error
I keep receiving a Cannot invoke “com.***.repositories.UserRepository.findByEmail(String)” because “this.userRepository” is null error everytime I try to process my /register method. I can’t figure out why the code is coming across as null. Controller – Axios call – My UserRepository – Answer Simply add @Autowired to your related fields you want to get Autowired by spring. Change your code from to
How do I work with a REST API in Java that returns a zip file?
I am familiar with the basics of making a GET request in Java using the HttpURLConnection class. In a normal situation where the return type would be a JSON, I’d do something like this: However, the current endpoint I’m trying to work with sends back a zip file containing various types of files. The ‘Content-Type’ in that case would be
How do I get a column value from multiple sheets
I have a working script to create a Google Doc from a Google Form, but I want to change one of my values to sheet2. I am using sheet2 to =CLEAN a column due to line breaks I can’t get rid of in column 3 on sheet1. I replicated my script for a simple form/doc below to test. I want
REST API Send multiples errors in a JSON Array at the same time with JAX-RS
I’m learning how to create an API with Java EE and JAX-RS. But I could not find any answer about my problem on internet. I have a route “signup” : Currently, to send all the error message I need, I’m using this: This code send me basically this type of Response: This is what I want, but the code is
How to get access token from Spotify API? [java]
I am fairly new to programming with Java but am interested in creating a program that allows for connection to the Spotify API. I am using the Client Credential Flow authorization process but keep getting java.io.IOException: insufficient data written exception when trying to reach the access token. I cannot figure out what information I am missing to complete the request.
Rest-Assured – How to validate response body with POJO
I’m freshman in Rest-Assured. I have a simple test which gets response body and I want to validate whether the response body matches with my POJO class. Here is my test: Here is my POJO class: So how to validate that the response body structure is equal to my POJO class? Thanks in advance Answer Try the approach like this:
Trying to search through JSON in Java
I am using the Marvel API to try and get the names of heroes based on what the user has typed inside of the search box. The search functionality works I am pretty sure as it will search through a …
How to secure an API REST for mobile app? (if sniffing requests gives you the “key”)
It’s probable a newbie question but I’ll try to create an interesting debate. I know there are some authentication methods for API Basic Authentication, API Keys, OAuth 2.0 … all of those methods add a header or a formData param in the request. Although you use SSL, it’s “usually easy” to hack mobile apps (I’m thinking in Android right now:
Sending POST request with POSTMAN to Java REST API and getting null values in the xml response
I am creating a REST Service in Java and now I am building the post method which has 2 parameters that has to be inputted as xml in postman (for test) and get a response as xml in java and insert it in database. For starters I am trying to add the values as Query Params in POSTMAN with key