0

I am sending a API request to a third party system called quip and I am trying to extract a particular URL from the JSON response that I am receiving on that call, through apex code.

The JSON response that I received is as below.

{
    "thread": {
        "author_id": "BYcAEAdoIKH",
        "thread_class": "document",
        "id": "TcKAAATn9vB",
        "created_usec": 1608537827055469,
        "updated_usec": 1609922848552867,
        "title": "Test Document",
        "link": "https://akshayssample.quip.com/6dztAy1U55QA",
        "type": "document",
        "is_template": false,
        "document_id": "TcKABAVKJXl",
        "is_deleted": false
    },
    "user_ids": [
        "BYcAEAdoIKH"
    ],
    "shared_folder_ids": [],
    "expanded_user_ids": [
        "BYcAEAdoIKH"
    ],
    "invited_user_emails": [],
    "access_levels": {
        "BYcAEAdoIKH": {
            "access_level": "OWN"
        }
    },
    "html": "<h1 id='TcKACA8mt5x'>Test Document</h1>\n\n<p id='TcKACAl6fcp' class='line'>Test Document this quip has 30 days validity</p>\n\n<p id='TcKACAcqUy0' class='line'>​</p>\n\n<p id='TcKACAR2wzT' class='line'>Example 1: Via Project Tracker</p>\n\n<div id='TcKACAgI1vR' data-unique-id='TcKACAgI1vR-1106e9bfd0dd40127001dc978b4eed2a' data-live-app-id='JdGAjAc35Es' data-live-app-payload='{&quot;columns&quot;:[{&quot;content&quot;:&quot;Project\\n&quot;,&quot;type&quot;:&quot;TEXT&quot;,&quot;id&quot;:&quot;0&quot;},{&quot;content&quot;:&quot;Owner\\n&quot;,&quot;type&quot;:&quot;PERSON&quot;,&quot;id&quot;:&quot;1&quot;},{&quot;content&quot;:&quot;Tags\\n&quot;,&quot;type&quot;:&quot;TEXT&quot;,&quot;id&quot;:&quot;2&quot;},{&quot;content&quot;:&quot;Status\\n&quot;,&quot;type&quot;:&quot;STATUS&quot;,&quot;id&quot;:&quot;3&quot;,&quot;options&quot;:[{&quot;label&quot;:&quot;Upcoming&quot;,&quot;devName&quot;:&quot;upcoming&quot;,&quot;color&quot;:&quot;BLUE&quot;},{&quot;label&quot;:&quot;In Progress&quot;,&quot;devName&quot;:&quot;in_progress&quot;,&quot;color&quot;:&quot;YELLOW&quot;},{&quot;label&quot;:&quot;Complete&quot;,&quot;devName&quot;:&quot;complete&quot;,&quot;color&quot;:&quot;GREEN&quot;}]},{&quot;content&quot;:&quot;Deadline\\n&quot;,&quot;type&quot;:&quot;DATE&quot;,&quot;id&quot;:&quot;4&quot;},{&quot;content&quot;:&quot;Attachment\\n&quot;,&quot;type&quot;:&quot;FILE&quot;,&quot;id&quot;:&quot;5&quot;}],&quot;rows&quot;:[{&quot;0&quot;:&quot;Test Lead Check\\n&quot;,&quot;1&quot;:[],&quot;2&quot;:&quot;proposal\\n&quot;,&quot;3&quot;:&quot;complete&quot;,&quot;4&quot;:1608057000000,&quot;5&quot;:null},{&quot;0&quot;:&quot;Testing Lead check\\n&quot;,&quot;1&quot;:[],&quot;2&quot;:&quot;Approved\\n&quot;,&quot;3&quot;:&quot;in_progress&quot;,&quot;4&quot;:1608834600000,&quot;5&quot;:null},{&quot;0&quot;:&quot;New Project\\n&quot;,&quot;1&quot;:[],&quot;2&quot;:&quot;&quot;,&quot;3&quot;:null,&quot;4&quot;:null,&quot;5&quot;:null}]}'><span id='TcKACAY2l2u'>Test Lead Check</span>\n\n<br/><span id='TcKACAeGNEs'>proposal</span>\n\n<br/><span id='TcKACAUWAcW'>Testing Lead check</span>\n\n<br/><span id='TcKACArfx8H'>Approved</span>\n\n<br/><span id='TcKACAo8fUr' class='default-content'>New Project</span>\n\n<br/><span id='TcKACAhABzK'>​</span>\n\n<br/><span id='TcKACA9hIn3'>Project</span>\n\n<br/><span id='TcKACA0cVGz'>Owner</span>\n\n<br/><span id='TcKACAxi2o3'>Tags</span>\n\n<br/><span id='TcKACAy5PZ8'>Status</span>\n\n<br/><span id='TcKACARLGtn'>Deadline</span>\n\n<br/><span id='TcKACADK9Vg'>Attachment</span>\n\n<br/></div><p id='TcKACA0KqbY' class='line'><control data-remapped=\"true\" id=\"TcKACAQA1kH\"><a href=\"https://akshayssample.quip.com/-/blob/TcKAAATn9vB/9iCERdaL6YP6j0y-ze9o4w?name=SFDC%20AKV.docx\">SFDC AKV.docx</a></control></p>\n\n<p id='TcKACAJuY4n' class='line'><control data-remapped=\"true\" id=\"TcKACAVpSwb\"><a href=\"https://akshayssample.quip.com/-/blob/TcKAAATn9vB/kyOZUAjFjnv0-5_ShQIpEQ?name=ApexPMD_1609858248573slqSBon3PhTue%20Jan%2005%202021%2020_20_48%20GMT%2B0530%20(India%20Standard%20Time).csv\">ApexPMD_1609858248573slqSBon3PhTue Jan 05 2021 20_20_48 GMT+0530 (India Standard Time).csv</a></control></p>\n\n<p id='TcKACANxeYA' class='line'>​</p>\n\n<p id='TcKACAHQHC7' class='line'>Example 2: Via Direct attachment</p>\n\n<p id='TcKACAxZ2Qn' class='line'><control data-remapped=\"true\" id=\"TcKACAYI7oQ\"><a href=\"https://akshayssample.quip.com/-/blob/TcKAAATn9vB/sZJVCFNguBPv7HFm8QZzlQ?name=update%20Opportunity%20flow%20discussion.txt\">update Opportunity flow discussion.txt</a></control></p>\n\n<p id='TcKACAOOv2R' class='line'>​</p>\n\n<p id='TcKACAiz0oL' class='line'>Example 3: Via spreadsheet</p>\n\n<div data-section-style='13'><table id='TcKACAo6Fno' title='Sheet1' style='width: 24em'><thead><tr><th class='empty' style='width: 2em'/><th id='TcKACAqBVic' class='empty' style='width: 6em'>A<br/></th><th id='TcKACApTSC2' class='empty' style='width: 6em'>B<br/></th><th id='TcKACAW0ObX' class='empty' style='width: 6em'>C<br/></th><th id='TcKACAToE9M' class='empty' style='width: 6em'>D<br/></th></tr></thead><tbody><tr id='TcKACAX6Oa3'><td style='background-color:#f0f0f0'>1</td><td id='s:TcKACAX6Oa3_TcKACAKWd6Z' style=''><span id='s:TcKACAX6Oa3_TcKACAKWd6Z'>Name</span>\n\n<br/></td><td id='s:TcKACAX6Oa3_TcKACAuBdRM' style=''><span id='s:TcKACAX6Oa3_TcKACAuBdRM'>Tags</span>\n\n<br/></td><td id='s:TcKACAX6Oa3_TcKACAYllhv' style=''><span id='s:TcKACAX6Oa3_TcKACAYllhv'>Date</span>\n\n<br/></td><td id='s:TcKACAX6Oa3_TcKACAH7P9M' style=''><span id='s:TcKACAX6Oa3_TcKACAH7P9M'>Attachments</span>\n\n<br/></td></tr><tr id='TcKACA9luEu'><td style='background-color:#f0f0f0'>2</td><td id='s:TcKACA9luEu_TcKACAKWd6Z' style=''><span id='s:TcKACA9luEu_TcKACAKWd6Z'>Opp update File</span>\n\n<br/></td><td id='s:TcKACA9luEu_TcKACAuBdRM' style=''><span id='s:TcKACA9luEu_TcKACAuBdRM'>trueinfluence</span>\n\n<br/></td><td id='s:TcKACA9luEu_TcKACAYllhv' style=''><span id='s:TcKACA9luEu_TcKACAYllhv'><control data-remapped=\"true\" id=\"TcKACAboGkL\">Wednesday, January 6</control></span>\n\n<br/></td><td id='s:TcKACA9luEu_TcKACAH7P9M' style=''><span id='s:TcKACA9luEu_TcKACAH7P9M'> <control data-remapped=\"true\" id=\"TcKACAu4qOm\"><a href=\"https://akshayssample.quip.com/-/blob/TcKAAATn9vB/sZJVCFNguBPv7HFm8QZzlQ?name=update%20Opportunity%20flow%20discussion.txt\">update Opportunity flow discussion.txt</a></control> </span>\n\n<br/></td></tr><tr id='TcKACA4n1Ls'><td style='background-color:#f0f0f0'>3</td><td id='s:TcKACA4n1Ls_TcKACAKWd6Z' style=''><span id='s:TcKACA4n1Ls_TcKACAKWd6Z'>​</span>\n\n<br/></td><td id='s:TcKACA4n1Ls_TcKACAuBdRM' style=''><span id='s:TcKACA4n1Ls_TcKACAuBdRM'>​</span>\n\n<br/></td><td id='s:TcKACA4n1Ls_TcKACAYllhv' style=''><span id='s:TcKACA4n1Ls_TcKACAYllhv'>​</span>\n\n<br/></td><td id='s:TcKACA4n1Ls_TcKACAH7P9M' style=''><span id='s:TcKACA4n1Ls_TcKACAH7P9M'>​</span>\n\n<br/></td></tr><tr id='TcKACAYwS68'><td style='background-color:#f0f0f0'>4</td><td id='s:TcKACAYwS68_TcKACAKWd6Z' style=''><span id='s:TcKACAYwS68_TcKACAKWd6Z'>​</span>\n\n<br/></td><td id='s:TcKACAYwS68_TcKACAuBdRM' style=''><span id='s:TcKACAYwS68_TcKACAuBdRM'>​</span>\n\n<br/></td><td id='s:TcKACAYwS68_TcKACAYllhv' style=''><span id='s:TcKACAYwS68_TcKACAYllhv'>​</span>\n\n<br/></td><td id='s:TcKACAYwS68_TcKACAH7P9M' style=''><span id='s:TcKACAYwS68_TcKACAH7P9M'>​</span>\n\n<br/></td></tr><tr id='TcKACAeR3Jp'><td style='background-color:#f0f0f0'>5</td><td id='s:TcKACAeR3Jp_TcKACAKWd6Z' style=''><span id='s:TcKACAeR3Jp_TcKACAKWd6Z'>​</span>\n\n<br/></td><td id='s:TcKACAeR3Jp_TcKACAuBdRM' style=''><span id='s:TcKACAeR3Jp_TcKACAuBdRM'>​</span>\n\n<br/></td><td id='s:TcKACAeR3Jp_TcKACAYllhv' style=''><span id='s:TcKACAeR3Jp_TcKACAYllhv'>​</span>\n\n<br/></td><td id='s:TcKACAeR3Jp_TcKACAH7P9M' style=''><span id='s:TcKACAeR3Jp_TcKACAH7P9M'>​</span>\n\n<br/></td></tr><tr id='TcKACAYVnwN'><td style='background-color:#f0f0f0'>6</td><td id='s:TcKACAYVnwN_TcKACAKWd6Z' style=''><span id='s:TcKACAYVnwN_TcKACAKWd6Z'>​</span>\n\n<br/></td><td id='s:TcKACAYVnwN_TcKACAuBdRM' style=''><span id='s:TcKACAYVnwN_TcKACAuBdRM'>​</span>\n\n<br/></td><td id='s:TcKACAYVnwN_TcKACAYllhv' style=''><span id='s:TcKACAYVnwN_TcKACAYllhv'>​</span>\n\n<br/></td><td id='s:TcKACAYVnwN_TcKACAH7P9M' style=''><span id='s:TcKACAYVnwN_TcKACAH7P9M'>​</span>\n\n<br/></td></tr></tbody></table></div><p id='TcKACAco2iv' class='line'>Example 4: Via checkbox</p>\n\n<div data-section-style='7' style=\"\" class=\"\"><ul id='TcKACAgJkaJ'><li id='TcKACAhId44' class='' value='1'><span id='TcKACAhId44'><control data-remapped=\"true\" id=\"TcKACAiBzKb\"><a href=\"https://akshayssample.quip.com/-/blob/TcKAAATn9vB/sZJVCFNguBPv7HFm8QZzlQ?name=update%20Opportunity%20flow%20discussion.txt\">update Opportunity flow discussion.txt</a></control></span>\n\n<br/></li></ul></div>"
}

In this response, under the value of the key "html", there is a href value with the URL "https://akshayssample.quip.com/-/blob/TcKAAATn9vB/kyOZUAjFjnv0-5_ShQIpEQ?name=ApexPMD_1609858248573slqSBon3PhTue%20Jan%2005%202021%2020_20_48%20GMT%2B0530%20(India%20Standard%20Time)" I am trying to access that particularly. Can someone please let me know how I can extract that value through code?

1
  • There are many href inside the html key. Which one should be taken? Also what have you tried so far? Jan 6 at 10:57

Browse other questions tagged or ask your own question.