Forum Discussion

DMcCabe's avatar
DMcCabe
Contributor
11 years ago

Passing Response field into URI path for next test

I am doing a post to a REST webservice to create a subscriber resource. When the resource is successfully created I get
{
"_links": {
"curie": {
"href": "/rels/{rel}",
"name": "rels",
"templated": true
},
"self": {
"href": "/subscribers/13"
},
"rels:add-site": {
"href": "/subscribers/13/sites"
},
"rels:delete-subscriber": {
"href": "/subscribers/13"
},
"rels:list-sites": {
"href": "/subscribers/13/sites"
},
"rels:update-subscriber": {
"href": "/subscribers/13"
},
"up": {
"href": "/subscribers"
}
},
"email": "p.smith@xyz.com",
"firstName": "Patrick",
"lastName": "Smith",
"organization": null,
"phone": null,
"salesForceId": null,
"url": "www.xyz.com"
}

I want to say delete that subscriber then. To do so I parse out the href value out of the following:
"rels:delete-subscriber": {
"href": "/subscribers/13"

and add /subscribers/13 to the base url and do a delete http request.

How can I add /subscribers/13 to the base url of the next test case?

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    I'd use a HTTP TestStep and use a PropertyExpansion in the URL field.

    Regards

    Henrik O
    SmartBear Software
  • Ok got that passing the value using both the REST test step and the HTTP test step. However, it's passing the value url encoded ie. subscribers%2F23 instead of subscribers/23 and as a result I am getting 404. Anyway to stop that happening?
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    If you double-click on the method that was defined for your REST request, there's a checkbox "Disable Encoding". Check that checkbox.

    Let me know if you still see the issue afterwards. Thanks,
    Michael Giller
    SmartBear Software