I want to serve an image to a client by converting it to a byte but for some reason byteArrayOutputStream.toByteArray() is empty. I get a response status of 200 which means it is served. I looked at various documentations on reading an image file from a directory using BufferedImage and then converting BufferedImage to a byteArray from oracle https://docs.oracle.com/javase/tutorial/2d/images/loadimage.html and
Tag: api
Sending an email at a specific time using spring boot [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago. Improve this question in the application I am developing I can specify an expiration date of a license and now I want to
What are the best practices for calculating statistics in REST API applications
I am trying to make a service that will calculate statistics for each month. I did smth like this: But it takes a long time if there are lots of etries in the database. Are there any best practices for working with statistics in REST API applications? And also I’d like to know if it is a good way to
How to find the length or size of the elements of response array in rest assured
I am new to rest assured. I have tried below code for getting response This is JSON response How do I get the length or size of the elements of that array. Answer As above comment, the length here is the number of key-value pair in the json object. For me, you can choose any object in the array to
Specifying sort order direction in a JSON API
Does Restful API define proper ways to give Sort Order Direction, (Ascending or Descending) for API user parameters ? I am letting a user input a request string, that only allows two options for API to work “Ascending” or “Descending” . Is there a more formal way of doing this per standards? Request: Specifying sort order in a JSON API
Unable to receive data out of api call with webclient
So I’m trying to get my head around the webclient, but I keep getting a nullpointerexception, though my test work fine and say that object is not null. I also see my console making connection to the api. But when I ask the value, I get null. Here are the two objects I use for it: and then here I
How to customize sso(single sign on) by keycloak?
sorry for my poor english… I ‘ll do my best to write question. Basically, keycloak provide loginPage where login form has a some name and value parameter determined by keycloak (forexample session_code, excustion, client_id, tab_id). this way is Server side randering(SSR). However, I want to login process with keycloak in API way. In this case, it’s not possible to use
Deserialise API Response of PlayWright using Java
I am exploring playwright for automating api tests and I am unable to deserialise APIResponse of playwright to a POJO using java. I used to do this with rest assured using following code: Answer I managed to do this with the help of ObjectMapper.
How to properly convert HashMap<String,List> to Json with array of json object
I have a stream of Kafka messages and wanted to build a HashMap<String,List<Object>> to be used as API response in Json format. expected response: actual response: Answer It is now working using these changes: Convert Kafka message string to JSONObject new JSONObject(consumerRecord.value()) Construct a JSONObject from a Map using jsonObject = new JSONObject(responses); Return Map<String, Object> using jsonObject.toMap();
Throwing custom errors as Json when a parameter is invalid
I am working on an API and need to throw and exception that looks like this if the sort by parameter is not one of my predetermined values, i have a few parameters to do this for here is what my controller looks like ive remove the url but it works for sorting the incoming data but i need to