<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: API Call get the response in JSON and extract the data in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184235#M73282</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44443/gkpshakeel.html" nodeid="44443" target="_blank"&gt;@Shakeel Ahmad&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You need to use &lt;STRONG&gt;InvokeHTTP processor&lt;/STRONG&gt; to get response back from the API.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;InvokeHTTP Configs:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;change the &lt;STRONG&gt;Remote URL&lt;/STRONG&gt; property value to your &lt;STRONG&gt;url&lt;/STRONG&gt; that gives back you &lt;STRONG&gt;required response&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45773-invokehttp.png" style="width: 1957px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19004iD1BF52DC87B35476/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45773-invokehttp.png" alt="45773-invokehttp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Change the Username,Password property values also.&lt;/P&gt;&lt;P&gt;In this invoke http processor will get the JSON response and then you need to use &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Evaluate Json Path processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45774-eval-json.png" style="width: 1801px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19005i3DC10ECD96EDC3B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45774-eval-json.png" alt="45774-eval-json.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if you are going to extract only one attribute then you need to add new property that matches with the Json attribute.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1.If your json response is flattened as like below&lt;/P&gt;&lt;PRE&gt;{
    "id": "1",
    "Certificate": "HCC"
  }&lt;/PRE&gt;&lt;P&gt;Then the output of EvalJsonpath processor with above Configs would be&lt;/P&gt;&lt;PRE&gt;HCC&lt;/PRE&gt;&lt;P&gt;2.If your json response is like below&lt;/P&gt;&lt;PRE&gt;{
  "data": {
    "id": "1",
    "Certificate": "HCC"
  }
}
&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Configs of EvalJSON Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45776-evaljson.png" style="width: 1862px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19006iDD0463C232BD4051/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45776-evaljson.png" alt="45776-evaljson.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see above screenshot&lt;STRONG&gt; i have changed the Certificate Property value&lt;/STRONG&gt; as my JSON response &lt;STRONG&gt;Certificate is inside the data list.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;so i have matched the Certificate attribute using &lt;STRONG&gt;$.data.Certificate&lt;/STRONG&gt; which will result the &lt;STRONG&gt;output &lt;/STRONG&gt;as&lt;/P&gt;&lt;PRE&gt;HCC&lt;/PRE&gt;&lt;P&gt;You need to &lt;STRONG&gt;change the Certificate property value as per your JSON Response.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Once you get output from the &lt;STRONG&gt;EvaluateJSONPath processor&lt;/STRONG&gt; the results are stored in a File, You can store the&lt;STRONG&gt; file using &lt;/STRONG&gt;PutFile(or)PutHDFS...etc&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Flow:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45778-flow.png" style="width: 2445px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19007iD91B1EC4D04F990B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45778-flow.png" alt="45778-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Aug 2019 08:36:12 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T08:36:12Z</dc:date>
    <item>
      <title>API Call get the response in JSON and extract the data</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184234#M73281</link>
      <description>&lt;P&gt;@&lt;A href="https://community.hortonworks.com/users/641/mburgess.html"&gt;Matt Burgess&lt;/A&gt; 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 &lt;/P&gt;&lt;P&gt;details are as following :&lt;/P&gt;&lt;P&gt;&lt;A href="https://hpe-api.sabacloud.com/v1/login" target="_blank"&gt;https://hpe-api.sabacloud.com/v1/login&lt;/A&gt; &lt;/P&gt;&lt;P&gt;site:NA2PRD0002 &lt;/P&gt;&lt;P&gt;password:restWS0808 &lt;/P&gt;&lt;P&gt;user:WS_ADMIN &lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 16:01:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184234#M73281</guid>
      <dc:creator>gkp_shakeel</dc:creator>
      <dc:date>2018-01-09T16:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: API Call get the response in JSON and extract the data</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184235#M73282</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/44443/gkpshakeel.html" nodeid="44443" target="_blank"&gt;@Shakeel Ahmad&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You need to use &lt;STRONG&gt;InvokeHTTP processor&lt;/STRONG&gt; to get response back from the API.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;InvokeHTTP Configs:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;change the &lt;STRONG&gt;Remote URL&lt;/STRONG&gt; property value to your &lt;STRONG&gt;url&lt;/STRONG&gt; that gives back you &lt;STRONG&gt;required response&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45773-invokehttp.png" style="width: 1957px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19004iD1BF52DC87B35476/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45773-invokehttp.png" alt="45773-invokehttp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Change the Username,Password property values also.&lt;/P&gt;&lt;P&gt;In this invoke http processor will get the JSON response and then you need to use &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Evaluate Json Path processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45774-eval-json.png" style="width: 1801px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19005i3DC10ECD96EDC3B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45774-eval-json.png" alt="45774-eval-json.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if you are going to extract only one attribute then you need to add new property that matches with the Json attribute.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1.If your json response is flattened as like below&lt;/P&gt;&lt;PRE&gt;{
    "id": "1",
    "Certificate": "HCC"
  }&lt;/PRE&gt;&lt;P&gt;Then the output of EvalJsonpath processor with above Configs would be&lt;/P&gt;&lt;PRE&gt;HCC&lt;/PRE&gt;&lt;P&gt;2.If your json response is like below&lt;/P&gt;&lt;PRE&gt;{
  "data": {
    "id": "1",
    "Certificate": "HCC"
  }
}
&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Configs of EvalJSON Processor:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45776-evaljson.png" style="width: 1862px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19006iDD0463C232BD4051/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45776-evaljson.png" alt="45776-evaljson.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see above screenshot&lt;STRONG&gt; i have changed the Certificate Property value&lt;/STRONG&gt; as my JSON response &lt;STRONG&gt;Certificate is inside the data list.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;so i have matched the Certificate attribute using &lt;STRONG&gt;$.data.Certificate&lt;/STRONG&gt; which will result the &lt;STRONG&gt;output &lt;/STRONG&gt;as&lt;/P&gt;&lt;PRE&gt;HCC&lt;/PRE&gt;&lt;P&gt;You need to &lt;STRONG&gt;change the Certificate property value as per your JSON Response.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Once you get output from the &lt;STRONG&gt;EvaluateJSONPath processor&lt;/STRONG&gt; the results are stored in a File, You can store the&lt;STRONG&gt; file using &lt;/STRONG&gt;PutFile(or)PutHDFS...etc&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Flow:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45778-flow.png" style="width: 2445px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19007iD91B1EC4D04F990B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45778-flow.png" alt="45778-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Aug 2019 08:36:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184235#M73282</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T08:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: API Call get the response in JSON and extract the data</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184236#M73283</link>
      <description>&lt;P&gt;Thanks Lot @&lt;A href="https://community.hortonworks.com/users/18929/yaswanthmuppireddy.html" rel="nofollow noopener noreferrer" target="_blank"&gt;Shu&lt;/A&gt; for your details description explanation. My Flow now look like as below .Thanks Lot&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="45792-fullflowofapiconfiguration.png" style="width: 1290px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19003iBBD822FE5014AC73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="45792-fullflowofapiconfiguration.png" alt="45792-fullflowofapiconfiguration.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 08:35:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/API-Call-get-the-response-in-JSON-and-extract-the-data/m-p/184236#M73283</guid>
      <dc:creator>gkp_shakeel</dc:creator>
      <dc:date>2019-08-18T08:35:47Z</dc:date>
    </item>
  </channel>
</rss>

