Pentaho rest client with variable url - pentaho

I'm new to Pentaho and using the Rest Client. I can get the Rest client to work by using generate rows for the url. But then I need to pass part of the result of the json to be part of the url for the next request. I'm not sure how to do this. Any suggestions.

Remember that PDI works with streams, you, for each REST request you made, you will have one row as result. You will have as many rows as many requests you do.
I'm not sure if you can deserialize the JSON object directly from the PDI interface, but in the worst scenario, you can use the "User Defined Java Class" to use some external library (like Gson) and deserialize the object.
Then, you can create another variable in the UDJC step and concatenate the attributes you need on the URL string that comes from the last step.
In the other hand you can use "Modified Javascript" to deserialize it and return the attributes you need to then concatenate it with the URL. To use it, just declare varibles inside the code, and then use "Get variables" button to retrieve the available fields to send to the next step.
There are many ways to do it, I suggest you to use the Modified Javascript because it's easier to handle.

You CAN parse the Json response, just use Json Input a a nex step, and then use XPath to parse the field you want: $.result.the.thing.u.want.

Related

How to define REST API with to Parameter

I am currently working on a REST API for a project. In the process I should search for events. I would like to make an endpoint for searching events in a period. That is, specify two parameters with from - to.
For the search you normally take a GET operation. My question is now it makes sense to specify two parameters in the path or should I rather fall back to a POST operation for something like that.
Example for the path /Events{From}{To}
Is this even feasible with multiple parameters?
If you are not making a change on the resource, you should use GET operation.
More detailed explanation:
If you were writing a plain old RPC API call, they could technically interchangeable as long as the processing server side were no different between both calls. However, in order for the call to be RESTful, calling the endpoint via the GET method should have a distinct functionality (which is to get resource(s)) from the POST method (which is to create new resources).
GET request with multiple parameters: /events?param1=value1&param2=value2
GET request with an array as parameter: /events?param=value1,value2,value3

Update single attribute with Restkit

I want to update ONE SINGLE attribute on the Core Data Object and send the change to the server using RestKit.
I see that ResKit is always sending Object with ALL attributes and not only with the changed ones. That makes my app slow(er).
I also see that update response from server should return whole object back to the RestKit which is again slower that it could be (All I need is success/failure response)
Is there elegant solution for this? (I am pretty new to the RestKit)
You can create a request descriptor on-the-fly which includes only the attributes you want to send, you would either simply need to use a mapping operation yourself or be sure to only run one such operation at a time and call removeRequestDescriptor: on the object manager (this could be tricky for you to manage). The alternate is to put the data to upload into a dictionary and upload that, but that isn't ideal.
For the response, the mapping says what to map but it doesn't all have to be there, RestKit will take whatever it can and map that.

mvc4 passing data between paging action and views

i have an action which will invoke a service (not database)to get some data for display,and i want to do paging on these data.however,every time a second page is clicked,it will invoke this action and of course invoke the service again,actually when i click the first page link,it already generate the whole data including what the second page needs. i just want to invoke the service once and get all the data,and later when paging,i don't need to invoke the service again,how can i deal with that?hope someone could give me a hint~
There are several ways to address this. If it's practical and a limited amount of data, it's ok to return the entire data set in the first request.
If that's your case I would consider returning a pure JSON object when you load the page initially. You can then deserialize this into a JS object variable on the web page that you can perform your paging operations against. This is an example of client side paging where all the data exists client side.
Another approach is to do Ajax based paging where you request the data for the next page as needed. I would still recommend returning JSON in this scenario as well.
The two approaches differ in that the first one returns all the data upfront, whereas the second one only returns what you need to render any given page.

Advantages of using a JSON string in the POST body as opposed to using key/value pairs in the POST body

What are the advantages of using a JSON string in the POST body as opposed to using key/value pairs in the POST body? It seems like there are a lot of API's out there that do it.
Example of what I mean: user={"username":"bob", "age":1} vs username=bob&age=1 in the POST form data.
When you use a JSON string, you just have to encode/decode your object and are ready to go. This especially useful when using multiple platforms.
Also, when you want to add new values/fields to your request, you just add it to the JSON object, instead of having to add extra validations in multiple files, possibly breaking code already works.
Another thing I can think of is that when using JSON you can code one single component with the only purpose of send/receive data, where you declare the function that will receive the decoded JSON and do whatever it wants with it. That way, you don't repeat code and let every function/class/file/whatever do the specific functionality it's meant to.

Create request with SOAP ui

Is it possible to create soap ui request with data ? right now I know how to create new request which gives you template what you should send to your webservice (which is read from you wsdl), is there a way so your requests fills with data based on type(ex: String,Integer, Date) from wsdl, from soap ui or any other test tool ? thank you
In Soap UI 4.5.1 there's an option under preferences that once set will auto populate new requests with dummy data that is type safe instead of the default '?'.
File->Preferences->WSDL Settings-> Tick option "Sample Values" and hit OK.
You can enter data directly into the XML request generated by SoapUI, you can write scripts to populate data, or if you have the Pro version, it gives you a GUI form, based on the request, where you can simply type the data. i.e. it makes a data-entry screen for you.
The pro version can also pull data from databases, generate data from a string list, etc.. for example, I recently needed to send several thousand SOAP payloads with dummy data for firstname/lastname, etc.. So I made up two string lists, one with first names of past and present NFL quaterbacks, one with last names. I had the data generator in SoapUI (Pro) randomly select a string from each, and submitted it in a stress test for 1000 iterations. The results were very useful, yet very amusing, giving names like Drew Montana.
Yes, you can use SOAPUI to complete this task. you can fetch your data from several sources like Excel,plain csv file,Database liks DB2,POSTGRES. You can also write your groovy scripts to control the flow.Various things you can do to achieve this...