Is it possible to send body in GET request using rest-assured - java

I'm using rest-assured on my test automation project and in one of my calls I need to send body in GET request, is that possible to do it in rest-assured and if yes how?

No. GET requests don't have a body. They don't need one, because with a GET request you don't send data to the server, GET requests are for GETting data from the server. Take a look at PUT and POST requests to send data to the server.

Related

Java jax-rs send HTTP GET Request accompanied with JSON Data Input

I'm using jax-rs library to create a client testing a Web Service by sending HTTP requests to it, for study purposes. Now a POST Request looks something like this:
Response res = target.
request().post(Entity.entity(jinput.toString(), MediaType.APPLICATION_JSON));
and GET Request something like this:
Response res = target.
request().accept(MediaType.APPLICATION_JSON).get(Response.class);
Where target is the targeted URI and jinput the JSON Input used to post a resource...
Now I wonder... is there a way I can send a GET Request accompanied with a JSON input? For the sake of testing how the Web Service reacts to it...
By using cURL to manually send HTTP requests I can do it... but is there a way I can do it using the jax-rs library?
Thanks in advance :)
P.S. I would like to test the same thing with a DELETE Request as well... if possible...

Getting data from post request in GWT client

I am trying to handle POST request in GWT. I did that in server side, but, i feel its work will be fine if the POST request is handled in client side. I was able to complete GET request in client side by reading the query string. But in case of POST, a file is being sent. How can i able to get the file from POST request in GWT client.
Thanks.
handling post request in GWT client is not possible. refer :
https://groups.google.com/forum/#!topic/google-web-toolkit/LOWMIPYcd7A

How can I send a GWT-RPC request with HttpClient?

I am using the Apache HTTPClient API to send HTTPRequests, and so far it's worked with standard requests. Now I want to send a GWT-RPC request and show the response, but I always receive the following error from the GWT-RPC server:
//EX[2,1,"com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException/3936916533","This application is out of date, please click the refresh button on your browser. ( Malformed or old RPC message received - expecting version 5 )"],0,5]
Actually, I have to send the following data with the request:
5|0|5|http://172.16.103.244:38081/kunagi/scrum.ScrumGwtApplication/|6E611C647A0C98D5A31A2506E16D81D6|scrum.client.ScrumService|startConversation|I|1|2|3|4|1|5|-1|
but I don't know how.
When I retrieve the request code from FireBug, I find the above data as a source in the post area.
Take a look at the gwt-syncproxy project. It does exactly what you are looking for, faking RCP calls from Java code. If you don't want to rely your project on gwt-syncproxy, you could look at it's implementation and find out how the create valid requests.

Getting post data from request

I'm writing a server side app in Java using the HttpCore library.
I have an HttpRequest and I'm trying to get the postdata sent from a form. The problem is- when I use request.getEntity() it returns a null object, even though when I look through HTTPFox on what kind of request I'm sending the post data is clearly there.
What am I doing wrong?
There seems to be some confusion. You are sending requests from a browser to the server. The server is likely using the servlet API. There you handle requests using the doPost(..) method of an HttpServlet. You have an HttpServletRequest from which you can get the parameters - request.getParameter("paramName")
HttpCore on the other hand is used to make requests, not to handle requests. It is used as an http client (in the role of the browser).

Google protocol buffers and servlets

I am wondering how I can use google protocol buffers to accept a request and send a response back to a client? I am thinking about writing a servlet which will take a request.
Is the following trail of thought the correct way to implement this:
1. Have a .proto file which is the message definition for the incoming request.
2. Write a servlet which accepts this request, does various tasks like querying database
and then sends a response. Will this response require a separate .proto message definition with all the fields that make up the response?
3. Will the client just invoke the doGet() method of my servlet and pass the request, it should then return a response as a protobuff object?
Any suggestion or idea will be very much appreciated.
Typically you'd want a request message and a response message, yes. You'd also probably want a method name to describe the action - that's certainly how the built-in PB services work.
The client wouldn't invoke doGet() - it would make a request (probably a POST rather than a GET) and your servlet would receive it.
Now, ideally you could have a general "ProtocolBufferServlet" which could service the requests by handing them off to services implementing the appropriate interfaces.
I suggest you look at the documentation for Protocol Buffer services and the Java services generated code for more information. You could implement an RpcChannel which worked over servlets, or get the client to make the HTTP post directly. You'd probably use dependency injection of some kind at the server side to tell the servlet what was implementing the service.
HI,
I have this up and running. I ended up posting a http request as a post to my servlet. I was able to take the request protocol buffer, read the request, do some processing and then send back a response. It was actually really simple once I got it working. We used the 1 .proto file to define the request and response message structure.

Categories

Resources