Created 01-09-2018 08:01 AM
@Matt Burgess I need one help I have one rest API and that API return the response in JSON format. In that JSON one attribute is Certificate and that attribute we need to save in the txt file. Could you help on that
details are as following :
https://hpe-api.sabacloud.com/v1/login
site:NA2PRD0002
password:restWS0808
user:WS_ADMIN
Created on 01-09-2018 09:48 AM - edited 08-18-2019 01:36 AM
You need to use InvokeHTTP processor to get response back from the API.
InvokeHTTP Configs:-
change the Remote URL property value to your url that gives back you required response.
Change the Username,Password property values also.
In this invoke http processor will get the JSON response and then you need to use
Evaluate Json Path processor:-
if you are going to extract only one attribute then you need to add new property that matches with the Json attribute.
Example:-
1.If your json response is flattened as like below
{ "id": "1", "Certificate": "HCC" }
Then the output of EvalJsonpath processor with above Configs would be
HCC
2.If your json response is like below
{ "data": { "id": "1", "Certificate": "HCC" } }
Configs of EvalJSON Processor:-
As you can see above screenshot i have changed the Certificate Property value as my JSON response Certificate is inside the data list.
so i have matched the Certificate attribute using $.data.Certificate which will result the output as
HCC
You need to change the Certificate property value as per your JSON Response.
Once you get output from the EvaluateJSONPath processor the results are stored in a File, You can store the file using PutFile(or)PutHDFS...etc
Flow:-
1.GenerateFlowFile Processor //Schedule to trigger InvokeHTTP processor 2.InvokeHTTP //Change the url,username,password property values and connect Response relation to EvalJsonPath 3.EvalJsonPath //add Certificate matching property value and connect matched relation to next processor if you are going to store the result into HDFS or Local then 4.PutHDFS(or)PutFile //to store the output file from EvalJsonPath to Local (or) HDFS
Created on 01-09-2018 09:48 AM - edited 08-18-2019 01:36 AM
You need to use InvokeHTTP processor to get response back from the API.
InvokeHTTP Configs:-
change the Remote URL property value to your url that gives back you required response.
Change the Username,Password property values also.
In this invoke http processor will get the JSON response and then you need to use
Evaluate Json Path processor:-
if you are going to extract only one attribute then you need to add new property that matches with the Json attribute.
Example:-
1.If your json response is flattened as like below
{ "id": "1", "Certificate": "HCC" }
Then the output of EvalJsonpath processor with above Configs would be
HCC
2.If your json response is like below
{ "data": { "id": "1", "Certificate": "HCC" } }
Configs of EvalJSON Processor:-
As you can see above screenshot i have changed the Certificate Property value as my JSON response Certificate is inside the data list.
so i have matched the Certificate attribute using $.data.Certificate which will result the output as
HCC
You need to change the Certificate property value as per your JSON Response.
Once you get output from the EvaluateJSONPath processor the results are stored in a File, You can store the file using PutFile(or)PutHDFS...etc
Flow:-
1.GenerateFlowFile Processor //Schedule to trigger InvokeHTTP processor 2.InvokeHTTP //Change the url,username,password property values and connect Response relation to EvalJsonPath 3.EvalJsonPath //add Certificate matching property value and connect matched relation to next processor if you are going to store the result into HDFS or Local then 4.PutHDFS(or)PutFile //to store the output file from EvalJsonPath to Local (or) HDFS
Created on 01-10-2018 03:16 AM - edited 08-18-2019 01:35 AM
Thanks Lot @Shu for your details description explanation. My Flow now look like as below .Thanks Lot