path-parameter

RestTemplate: How to send URL and query parameters together

淺唱寂寞╮ 提交于 2020-01-30 14:01:15
问题 I am trying to pass path param and query params in a URL but I am getting a weird error. below is the code String url = "http://test.com/Services/rest/{id}/Identifier" Map<String, String> params = new HashMap<String, String>(); params.put("id", "1234"); UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url) .queryParam("name", "myName"); String uriBuilder = builder.build().encode().toUriString(); restTemplate.exchange(uriBuilder , HttpMethod.PUT, requestEntity, class_p, params

WSO2 API Manager v1.8.0

喜你入骨 提交于 2019-12-25 04:47:14
问题 I have a simple use case of mapping path param from the API consumer to the backend API endpoint. I have done a lot of research but have not found out the specific answer on how to do that. As per my understanding, thr mapping of the path parameter can't be done without the use of uri-template. Now the problem is that the API Manager does not support uri-template from the API Publisher user interface and you have to use url-mapping instead. One blog from WSO2 developer says that you can then

Accept comma separated value in REST Webservice

隐身守侯 提交于 2019-12-22 08:23:34
问题 I am trying to receive a list of String as comma separated value in the REST URI ( sample : http://localhost:8080/com.vogella.jersey.first/rest/todo/test/1/abc,test , where abc and test are the comma separated values passed in). Currently I am getting this value as string and then splitting it to get the individual values. Current code : @Path("/todo") public class TodoResource { // This method is called if XMLis request @GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }

Using Query String in REST Web Services

泪湿孤枕 提交于 2019-12-17 22:17:10
问题 I thought one main characteristic and reason for using REST web services was to use path parameters rather than query parameters. But many publicly available REST web services use query parameters. Am I wrong in thinking that query parameters are not supposed to be used in REST web services? Is there a recommendation or rule about not using query parameters in REST web services? 回答1: The query string can still be used in REST web services just not in the same way as normal. You have to think

Wildcard path for servlet?

人盡茶涼 提交于 2019-12-17 15:58:46
问题 Having an @WebServlet(urlPatterns = "/myServlet/") . If the user goes to myapp/myServlet/other , I still want my servlet to catch. So to say, wildcard anything on after the servlet path. How could I do this? 回答1: You can use * as prefix or suffix wildcard. In your case, you can use /myServlet/* for a folder mapping. @WebServlet("/myServlet/*") The path info (the part after the mapping in the URL) is in the servlet by the way available as: String pathInfo = request.getPathInfo(); This would in

How to parse request parameter (query and path param) and request body in same POJO in REST API

五迷三道 提交于 2019-12-11 16:37:30
问题 I have a rest API (PUT verb) which accepts both request body and path params: Ex: curl --data {a:1, b:2} -X PUT "https://example.com/users/{username}/address/{addressname}" I am trying to fetch both request body and path param in one POJO Response myAPI(@BeanParam Users user){ system.out.println(user.username); system.out.println(user.a); Users class public class Users{ @PathParam(username) private String userName; ...... private String a; ...... } But I am getting value of user.a as null.

How to use path parameters in http.put request

≡放荡痞女 提交于 2019-12-11 15:23:18
问题 I want to know how to write the PUT request that sends parameters in the path. For example, dev changed the URL for the PUT request from a using a query string as parameters to using parameters in the path. When params were sent as query, I did something like this: let payload = { product_id: this.productId, customer_id: this.customerId, userGuide_id: this.userGuide } return this._$q((resolve, reject) => { this._$http.put(‘/api/products/customer/mostRecent’, payload) .then((result) => resolve

How to allow slashes in path param in jax-rs endpoint

萝らか妹 提交于 2019-12-10 23:32:18
问题 I have an endpoint as: @Path("/products") @Produces({ MediaType.APPLICATION_JSON }) public interface Products { @PUT @Path("/{productId}") .... } I have a jax-rs client implemented for this service and have it imported in the another service that I am calling this from. So I am calling the client as below from my second service public String updateProduct(String productId){ .. return client.target(this.getBaseUrl()).path("products/").path(productId).request(MediaType.APPLICATION_JSON_TYPE)

Jersey: @PathParam with commas to List<MyObject>

*爱你&永不变心* 提交于 2019-12-08 17:09:55
问题 I would like to call my Webservice with this pattern : /resource/1,2,3 And in my Class I want to bind my parameters to a List of Object @Path("/resource") public class AppWS { @GET @Path("/{params}") public Response get(@PathParam("params") List<MyObject> params) { return Response.status(200).entity("output").build(); } } With a simple Object: public class MyObject { Integer value; public MyObject(Integer value) { this.value = value; } } nb: If it possible I don't want to create an

Any way to get the path parameters in httpservlet request

家住魔仙堡 提交于 2019-12-06 05:51:09
问题 I have rest service implemented. I am trying to get the path parameters of the the request in filter. My request is /api/test/{id1}/{status} public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { //Way to get the path parameters id1 and status } 回答1: There's no other way to do it in a ServletFilter other than trying to parse the URI yourself, but you can access the path parameters if you decide to use a JAX-RS request filter: