0
votes

Problem is that I'm trying to change the settings of the website with POST and would like to confirm that the settings changed with a new GET request after the change, but as I'm running the collection it's just running the tests but not the POST itself, POST does not have any response so there's nothing to check there.

I hope that I was clear enough explaining my problem. Thanks Guys!

1
What does the request look like? Can you provide an example?Danny Dainton
Request to get the updated setting? It's just GET request to API where under query params I have the id of the setting. API will answer with "Settings": [ { "CasinoID": , "SettingID": , "SettingIntValue": , "SettingStringValue": "" } Post request is also posting just setting id and value to the APIZhockos

1 Answers

0
votes

If I'm understanding this correctly: You have two requests and want to run the GET immediately after the POST. This can simply be done by using environment variables and SetNextRequest.

Be careful of entering an infinite loop because Collections run top down; if your GET request was before the POST request. It may be better to duplicate your GET request and place it below the POST.

  1. A Post to {{base_url}}/website

Within the Pre-request Script set your new settings to your environment

pm.environment.set("setting1", "newValue");

Within the Body if your sending raw json for example use that variable

{
  "setting1": "{{setting1}}"
}

Postman still runs the Test section you don't need a pm.test it's essentially a Post-request Script. Tell Postman to run the GET request next:

postman.setNextRequest("Get Website Settings");
  1. From your Get request within Tests section validate the setting is correct
pm.test("Setting has been updated to" + {setting1}, function() {
    var actualSetting = pm.response.json().setting1;
    pm.expect(actualSetting).is.eql({setting1});
});