I am confused as to how to send a post request in Java with JSON parameters. I have seen many examples that use HttpPost library which I can not access. Below is my code: } class main { I am trying to pass the json in the main method (I know I am not doing it right), and was wondering
Tag: http
Copying Image from URL to HTTP URL
Someone is providing a S3 Presigned URL so that I can upload my images to that link. All my images are on the website. Is there a way in JAVA to copy the image URL to the new URL provided ? I am trying to do this. Seems like an overkill Answer There would be no point converting to BufferedImage
Mapping nested JSON values in a Java class
I can’t figure out how to handle nested JSON values in my Java classes. To make it simple as possible, I created four Java classes with every ‘nested level’. However, I’m trying to have all these values in one Java class. How can I do this? Json: Java classes: Answer You can club all the supporting classes in one class
Upload a file using Java 11 HttpClient to SpringBoot Server
My client upload method: My Spring Boot method that receives the file: The current error: What kind of headers can I add to ensure my Spring Boot server receives the file without errors? Answer MultipartException: Current request is not a multipart request This is telling you what’s wrong. In your code: .PUT(HttpRequest.BodyPublishers.ofFile(photo.toPath())), you are doing a PUT request with file’s
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.
Which HTTP status code is correct for Subscription cancel exception?
Which HTTP status code is correct for Subscription Canceled exception? I need to throw an exception when the user tries to accesses a certain page. I checked a few statuses like Payment Required, but it’s not satisfying the requirement. Any suggestion? Answer Which HTTP status code is correct for Subscription cancel exception? HTTP status codes belong to the transfer documents
How to return CREATED status (201 HTTP) in ResponseEntity
There is a Spring-MVC application. In controllers, when returning the results of methods, I return via ResponseEntity<>. On success, I return (200 statutes) the OK-method. But when creating something, I would like to return the CREATED-method (201 status). I just can’t understand what kind of URL to ask in parentheses when calling through CREATED. How can this be implemented? Now
Swagger codegen generates duplicated variables
I’m trying to generate client from yaml that contains That means, accept and contentType will be present in generated method signature. On top of that, I’v configured plugin like this Still, after mvn clean install I’m getting Error:(130,31) java: variable accept is already defined in method And generated code contains I’v tried different versions of plugin (from 2.3.0 up to
How to send a body with HTTP DELETE when using WebFlux?
I want to access an HTTP API which provides a DELETE endpoint. This particular endpoint expects a list of items (which I want to delete) as JSON body. Now, my problem is, I’m using Spring Webflux. But its WebClient doesn’t give me the possibility, to send a body with a DELETE request. For a POST, I’d do this: But for
How to map a JSON response to a Java class using Java 11 HttpClient and Jackson?
I’m new to the Java 11 HttpClient and would like to give it a try. I have a simple GET request that return JSON and I would like to map the JSON response to a Java class called Questionnaire. I understand that I can turn the response out of box into a String or an input stream like this How