How to validate specific keyword in response

I would like validate specific string in attribute value.

Please refer attached screenshot.

I would like to validate description has python string.

I had tried below snippets but it is not validating.

pm.test(“Body matches string”, function () {
pm.expect(pm.response.text()).to.include(“golang”);
});

pm.test(“Search Topic 1”, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.cards[1].description).include(pm.environment.get(“searchtopic1”));
});

Your second snippet is nearly there.

Array’s start at 0. (Although I’m not 100% sure that the cards element is an array, as you didn’t post that part of the response. (Therefore I’m assuming that its an array).

const jsonData = pm.response.json()

pm.test("Search Topic 1", function () {
    pm.expect(jsonData.cards[0].description).to.include("Python");
});

If this still fails, ensure that you are able to target the description by defining it as its own variable, and console logging it. You should maybe do the same for the search topic.

On a side note, you didn’t include a screenshot or details on what the error being returned was.

When posting code, please use the preformatted text option in the editor to stop all of the code being aligned to the left.