Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to create a Rest route in Talen ESB open studio. I have an endpoint which has multiple methods inside.I access my API from Metadata. how can I reroute each endpoint according to its method. lets say endpoint is http://Example/api/version/Method/operation. it has four methods Rawdata, balancing, customdata and final data. all these methods has multiple operations. http://Example/api/version/Rawdata/getRawdata
http://Example/api/version/Rawdata/getdatafromfields
http://Example/api/version/balancing/getfiltereddata
How can I tell talend that when I call Rawdata in Soapui send this endpoint. which components i can use or can Java code can do it? Any help would be appreciated.
Sorry about the delay in getting back to you here. I had to play around to figure this out. You may need to calculate your endpoint (in vs out) using some code in the cProcessor, but this is how you can switch them in the cREST_2.
Use the Relative Path to set the endpoint using a header. The way I tested this was as follows...
Give that a go and see what you think.
Sorry about the delay in getting back to you here. I had to play around to figure this out. You may need to calculate your endpoint (in vs out) using some code in the cProcessor, but this is how you can switch them in the cREST_2.
Use the Relative Path to set the endpoint using a header. The way I tested this was as follows...
Give that a go and see what you think.
@Richard Hall how you added these methods in "CamelHttpPath"?
I was trying to get the query parameter from the header.
The CamelHttpPath header is automatically set with the path you are calling which you've specified for the method. In the code above you appear to be looking for the CamelHttpQuery header.
@rhall it is throwing HTTP/1.1404 Not found
Probably it can't identify the method. can you please guide me how can to calculate endpoint (in vs out) using some code in the cProcessor. I mean any example?
I made sure that my methods were structured in exactly the same way as the methods of the API I am calling (just to keep it simple). So my methods look like this in my config......
The code in my cProcessor is just this.....
System.out.println(exchange.getIn().getHeader("CamelHttpPath"));
I am just using it to check the value of the header.
It produces the following. See that they match the methods I set up (apart from there being an actual number instead of the "{number}"....
/employees
/employee/1
/employee/2
In your cProcessor, you will need to get this value, compute the String you need for the API you care calling and set it to a new header value. Then use that header in the Relative Path of the cREST_2, as I showed the post above.
@Richard Hall I am able to deploy the route and call the methods. I have swagger specification in this route. I can see list of operations in my http://localhost:9001/services/api/swagger.json if I try to get some data then I get response code 404 no content. Since I used simple("${header.CamelHttpPath}") for my route and now swagger is not getting any parameters. Is there any way to pass the parameters to swagger?
If you're talking about query parameters (parameters provided in the URL with ? and &, etc), you can see these in the CamelHttpQuery header. If you need to use these, I suspect that there will be some String manipulation required.
@Richard Hall thank you for the response. yes I am talking about query parameter. but now where can I specify query parameter for swagger? in my CREST2 in Relative path I am already using simple("${header.CamelHttpPath}" + context.relativePath)