I am making a GET request in my java code and the URL that i want to use to perform a GET request is:
http://localhost:1111/sms/v1/222222?startTime=2015-12-29T14%3A00%3A00.000Z&endTime=2015-12-29T15%3A00%3A00.000Z
However it is coming up as:
http://localhost:1111/sms/v1/222222?startTime=2015-12-29T14%253A00%253A00.000Z&endTime=2015-12-29T15%253A00%253A00.000Z
Notice that the following characters are being replaced:
% to %25
How do I make sure my request is sent as I want to specify. My code looks like this:
public static String getRequest(String id, String startTs, String endTs) {
Response response = givenAuthJson("username", "password")
.queryParam("startTime", startTs)
.queryParam("endTime", endTs)
.get(BASE_URL+"/sms/v1/{id}", id);
response
.then()
.spec(responseSpec);
return response.asString();
}
And I call this method as:
.getRequest("222222", "2015-12-29T14%3A00%3A00.000Z","2015-12-29T15%3A00%3A00.000Z");
Can you please give an example or answer using the code given? Thanks.
OK - not sure if I'm allowed to answer my own Q but it is for the benefit of all if someone is doing the same thing as me!
I overcame this problem by adding the following
.urlEncodingEnabled(false)
REFERENCE:
how to handle Special character in query param value in Rest assured
Thanks for all who helped.
Related
I am having spring rest service where I am sending clob data(rich text field).i.e html data as string.
I can see service is returning fine(debug mode) but when it's coming to browser all double quotes" are getting converted with "\
That's why image rendering is not happening in rich text field.
Please help me to resolve this.
Rest Call:
Actual code I am unable to post due to access issue
#GetMapping(value="/getRTFData", produces ="application/json") public RTFData get() { }
RTFData class having field
String contentText;
Actual Service returning :
contentText = "<some src ="https://sample/viewImage/123"
but in response in swagger/postman i can see coming as
contentText ="<some src=\"https://sample/viewImage/123\">"
Which is extra \ whenever "(double quote).
Please help
I need to provide certain role for accessing a URL in the following format:
/connector/{programId}/order/{anything here}
Where programId is an integer value so I'd tried the following and it doesn't work at all.
.antMatchers('/connector/{programId:\\d+}/order/**').access("hasRole('CONNECTOR')")
But when I used ** instead of the programId part it's working well. But how can I make it work with pathVariable (which is always an integer).
You should use RegexRequestMatcher instead of AntPathRequestMatcher.
.regexMatchers("/connector/(\\d+)/order/.*").access("hasRole('CONNECTOR')")
I am using:
.regexMatchers("/connector/(\\d+)/order/.*").access("hasRole('CONNECTOR')")
But server response 405 error
I'm trying to redirect to a controller method which is taking Long and String as argument by using the reverse controller. I use version 2.4 of the play framework.
I've defined this route in the routes file:
GET /games/play/:id controllers.Games.renderGame(id: Long, feedback: String = "")
To call this route, I'm using in a other method redirect():
return redirect(controllers.routes.Games.renderGame(gameId, "test"));
And here is my renderGame() method:
public Result renderGame(Long id, String feedback) {
//do something
return ok(...);
}
In my opinion this actually should work but play gives me a error:
error: method renderGame in class ReverseGames cannot be applied to
given types;
IntelliJ is trying to do it better:
Error picture
If I define the method just with Long as parameter it's working fine but when a add the String I get the error again.
Any idea what's wrong here?
Related to this Question, it actually should work: Play Framework: Redirect to controller method with arguments
I fixed the problem by myself but it tooks me hours. The problem was that I used a = instead of =?. It has to look like this:
GET /games/play/:id controllers.Games.renderGame(id: Long, feedback: String ?= "")
I think the problem is with the route definition try adding feedback params at the url pattern
GET /games/play/:id/:feedback controllers.Games.renderGame(id: Long, feedback: String = "")
cheers.
I'm trying to configure a request to http: //where.yahooapis.com/v1/places.q(name_here);count=50?....
Not the best solution, I guess, but I tried
#GET("/v1/{location}")
Places getLocations(#Path("location") String locationName);
and pass there
getLocations("places.q(" + locationName + ");count=50");
But it still doesn't work as the string (); is translated into %28%29%3B.
Can you suggest any solutions? It would be better to dinamycally modify only the name_here part, something like
#GET("/v1/places.q({location});count=50)
If it is not possible how do I have to pass symbols (); so that they are converted correctly?
I just tried
#GET("/v1/places.q({location});count=50")
Places getLocations(#Path("location") String name)
a bit later and it works fine. I thought it will insert something like "/" or modify it, but it does exectly what I need.
I am using Jersey/java to create a web service that runs on tomca7.
When I pass a URL as a parameter in the #PathParam it does not display anything, but when it is a regular string it works fine.
Here is a modified demo of what I am doing..
For example if I put:
localhost/app/.../broaders/test
it will display: test
But if i put:
localhost/app/.../broaders/http%3A%2F%2Ftematres.befdata.biow.uni-leipzig.de%2Fvocab%2F%3Ftema%3D254
or even just
localhost/app/..../broaders/http%3A2F2F
it does not display anything.
#GET
#Path("broaders/{k}")
#produces(MediaType.APPLICATION_JSON)
#public String getBroader(#PathParam("k") String k){
return k;
}
I added the -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true to Catalina.proprieties but without luck.
Maybe you should pass the url as a parameter. Now, with the allow_encoded_slash you are generating urls that aren't broaders/XXXX but broaders/XXX/YYY/ZZZ so they don't match your regexp.
A #PathParam does not include / by default.
Try a regular expression for the #PathParam.
#Path("broaders/{k:.+}")