# How to extract value from link from a response body

**URL:** <https://community.postman.com/t/how-to-extract-value-from-link-from-a-response-body/38779>\
**Category:** Help Hub\
**Created:** [September 2, 2022, 4:36am UTC](https://community.postman.com/t/how-to-extract-value-from-link-from-a-response-body/38779 "2022-09-02T04:36:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthibee5](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@karthibee5](https://community.postman.com/u/karthibee5)\
**Post date:** [September 2, 2022, 4:36am UTC](https://community.postman.com/t/how-to-extract-value-from-link-from-a-response-body/38779/1 "2022-09-02T04:36:45Z")

</div>

Hi,  
Please help to extract value from the link as mentioned below from response.  
caller\_id is a look up value , after patch I get a response as below.  
Now I should compare the actual value with expected value .  
I have pasted the full response below .

```
"caller_id": {
  "link": "https://dev75644.service-now.com/api/now/table/sys_user/a8f98bb0eb32010045e1a5115206fe3a",
  "value": "a8f98bb0eb32010045e1a5115206fe3a"
},

```

Thanks  
Karthik

Response body :  
{  
“result”: {  
“parent”: “”,  
“made\_sla”: “true”,  
“caused\_by”: “”,  
“watch\_list”: “”,  
“upon\_reject”: “cancel”,  
“sys\_updated\_on”: “2022-09-02 04:18:30”,  
“child\_incidents”: “0”,  
“hold\_reason”: “”,  
“origin\_table”: “”,  
“task\_effective\_number”: “INC0010097”,  
“approval\_history”: “”,  
“number”: “INC0010097”,  
“resolved\_by”: “”,  
“sys\_updated\_by”: “admin”,  
“opened\_by”: {  
“link”: “[https://dev75644.service-now.com/api/now/table/sys\_user/6816f79cc0a8016401c5a33be04be441](https://dev75644.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441)”,  
“value”: “6816f79cc0a8016401c5a33be04be441”  
},  
“user\_input”: “”,  
“sys\_created\_on”: “2022-09-02 04:18:30”,  
“sys\_domain”: {  
“link”: “[https://dev75644.service-now.com/api/now/table/sys\_user\_group/global](https://dev75644.service-now.com/api/now/table/sys_user_group/global)”,  
“value”: “global”  
},  
“state”: “1”,  
“route\_reason”: “”,  
“sys\_created\_by”: “admin”,  
“knowledge”: “false”,  
“order”: “”,  
“calendar\_stc”: “”,  
“closed\_at”: “”,  
“cmdb\_ci”: “”,  
“delivery\_plan”: “”,  
“contract”: “”,  
“impact”: “3”,  
“active”: “true”,  
“work\_notes\_list”: “”,  
“business\_service”: “”,  
“business\_impact”: “”,  
“priority”: “5”,  
“sys\_domain\_path”: “/”,  
“rfc”: “”,  
“time\_worked”: “”,  
“expected\_start”: “”,  
“opened\_at”: “2022-09-02 04:18:30”,  
“business\_duration”: “”,  
“group\_list”: “”,  
“work\_end”: “”,  
“caller\_id”: {  
“link”: “[https://dev75644.service-now.com/api/now/table/sys\_user/a8f98bb0eb32010045e1a5115206fe3a](https://dev75644.service-now.com/api/now/table/sys_user/a8f98bb0eb32010045e1a5115206fe3a)”,  
“value”: “a8f98bb0eb32010045e1a5115206fe3a”  
},  
“reopened\_time”: “”,  
“resolved\_at”: “”,  
“approval\_set”: “”,  
“subcategory”: “”,  
“work\_notes”: “”,  
“universal\_request”: “”,  
“short\_description”: “”,  
“close\_code”: “”,  
“correlation\_display”: “”,  
“delivery\_task”: “”,  
“work\_start”: “”,  
“assignment\_group”: “”,  
“additional\_assignee\_list”: “”,  
“business\_stc”: “”,  
“cause”: “”,  
“description”: “caller\_id validation”,  
“origin\_id”: “”,  
“calendar\_duration”: “”,  
“close\_notes”: “”,  
“notify”: “1”,  
“service\_offering”: “”,  
“sys\_class\_name”: “incident”,  
“closed\_by”: “”,  
“follow\_up”: “”,  
“parent\_incident”: “”,  
“sys\_id”: “c513edbb97691110477f71571153af5b”,  
“contact\_type”: “”,  
“reopened\_by”: “”,  
“incident\_state”: “1”,  
“urgency”: “3”,  
“problem\_id”: “”,  
“company”: “”,  
“reassignment\_count”: “0”,  
“activity\_due”: “”,  
“assigned\_to”: “”,  
“severity”: “3”,  
“comments”: “”,  
“approval”: “not requested”,  
“sla\_due”: “”,  
“comments\_and\_work\_notes”: “”,  
“due\_date”: “”,  
“sys\_mod\_count”: “0”,  
“reopen\_count”: “0”,  
“sys\_tags”: “”,  
“escalation”: “0”,  
“upon\_approval”: “proceed”,  
“correlation\_id”: “”,  
“location”: “”,  
“category”: “inquiry”  
}  
}

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 2, 2022, 11:23am UTC](https://community.postman.com/t/how-to-extract-value-from-link-from-a-response-body/38779/2 "2022-09-02T11:23:49Z")

</div>

You need to parse the response into an object.

The basics on storing responses are covered in the Postman learning available through the learning center on the Postman homepage.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/d/8dcf19933ad8a29294d855176aba5d20044d8b28.png)

Skip down to Postman Training on the next page.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/c/9c83b640601d13efd516b5bde45670c5fc988f78.png)

From here, I recommend the Galaxy APIs 101, and Galaxy Testing and Automation as this covered all of the basics for me. This will include parsing responses.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/7/d79bc6fd4da3a12a0892c7de03455f232b64b321.png)

For more info on variables.

> **[Using variables | Postman Learning Center](https://learning.postman.com/docs/sending-requests/variables)**
>
> Using variables: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

Start here and if you still have issues, post what you’ve tried. Include screenshots and console logs (which are covered in the training).

The solution will be something similar to…

```auto
var objectTest = 
{
"result": {
"parent": "",
"made_sla": "true",
"caused_by": "",
"watch_list": "",
"upon_reject": "cancel",
"sys_updated_on": "2022-09-02 04:18:30",
"child_incidents": "0",
"hold_reason": "",
"origin_table": "",
"task_effective_number": "INC0010097",
"approval_history": "",
"number": "INC0010097",
"resolved_by": "",
"sys_updated_by": "admin",
"opened_by": {
"link": "https://dev75644.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441",
"value": "6816f79cc0a8016401c5a33be04be441"
},
"user_input": "",
"sys_created_on": "2022-09-02 04:18:30",
"sys_domain": {
"link": "https://dev75644.service-now.com/api/now/table/sys_user_group/global",
"value": "global"
},
"state": "1",
"route_reason": "",
"sys_created_by": "admin",
"knowledge": "false",
"order": "",
"calendar_stc": "",
"closed_at": "",
"cmdb_ci": "",
"delivery_plan": "",
"contract": "",
"impact": "3",
"active": "true",
"work_notes_list": "",
"business_service": "",
"business_impact": "",
"priority": "5",
"sys_domain_path": "/",
"rfc": "",
"time_worked": "",
"expected_start": "",
"opened_at": "2022-09-02 04:18:30",
"business_duration": "",
"group_list": "",
"work_end": "",
"caller_id": {
"link": "https://dev75644.service-now.com/api/now/table/sys_user/a8f98bb0eb32010045e1a5115206fe3a",
"value": "a8f98bb0eb32010045e1a5115206fe3a"
},
"reopened_time": "",
"resolved_at": "",
"approval_set": "",
"subcategory": "",
"work_notes": "",
"universal_request": "",
"short_description": "",
"close_code": "",
"correlation_display": "",
"delivery_task": "",
"work_start": "",
"assignment_group": "",
"additional_assignee_list": "",
"business_stc": "",
"cause": "",
"description": "caller_id validation",
"origin_id": "",
"calendar_duration": "",
"close_notes": "",
"notify": "1",
"service_offering": "",
"sys_class_name": "incident",
"closed_by": "",
"follow_up": "",
"parent_incident": "",
"sys_id": "c513edbb97691110477f71571153af5b",
"contact_type": "",
"reopened_by": "",
"incident_state": "1",
"urgency": "3",
"problem_id": "",
"company": "",
"reassignment_count": "0",
"activity_due": "",
"assigned_to": "",
"severity": "3",
"comments": "",
"approval": "not requested",
"sla_due": "",
"comments_and_work_notes": "",
"due_date": "",
"sys_mod_count": "0",
"reopen_count": "0",
"sys_tags": "",
"escalation": "0",
"upon_approval": "proceed",
"correlation_id": "",
"location": "",
"category": "inquiry"
}
}

console.log(objectTest);

pm.test('ObjectTest is an object', () => {
    pm.expect(objectTest).to.be.an('object');
});

console.log(objectTest.result.caller_id.value);
pm.collectionVariables.set("callerIdValue", objectTest.result.caller_id.value);
console.log(pm.collectionVariables.get("callerIdValue"));

```

---

<div class="post-metadata">

**Author:** ![karthibee5](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@karthibee5](https://community.postman.com/u/karthibee5)\
**Post date:** [September 2, 2022, 11:35am UTC](https://community.postman.com/t/how-to-extract-value-from-link-from-a-response-body/38779/3 "2022-09-02T11:35:14Z")

</div>

Many Thanks for your response.  
I think i did not frame my question well. Let me try to give more details  
i tried to patch caller\_id with value as “Abraham lincoln”

Expected caller id value is “Abraham lincoln” (Abraham Lincoln)  
but the actual value that comes in response is

note : caller id values are stored in different table “sys\_user”

“caller\_id”: {  
“link”: “[https://dev75644.service-now.com/api/now/table/sys\_user/a8f98bb0eb32010045e1a5115206fe3a](https://dev75644.service-now.com/api/now/table/sys_user/a8f98bb0eb32010045e1a5115206fe3a)”,  
“value”: “a8f98bb0eb32010045e1a5115206fe3a”  
},  
``

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 2, 2022, 4:27pm UTC](https://community.postman.com/t/how-to-extract-value-from-link-from-a-response-body/38779/4 "2022-09-02T16:27:20Z")

</div>

@karthibee5

Can you please elaborate more. I’m still unclear on what you are trying to assert against.

The whole response is in a result leaf. As far as I can tell, its a single result, and caller\_id only exists once.

In that sample response, the caller\_id has two attributes, a link and value.

Expanded here…

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/3/30f3406cf87b36dd28ca8442b59db3d04d5fc738.png)

I assumed that you wanted to assert\test that the value is the same as something you already have stored in a variable. Something from the sys\_table.

It’s always useful to post the request\response, and what you have tried before to add context.

```auto

var responseValue = objectTest.result.caller_id.value

pm.test('Value', () => {
    pm.expect(responseValue).to.eql(expectedValue); // where expectedValue is an already defined variable from a previous request
});

```
