mercredi 9 septembre 2020

Postman API - Variable generating but not passing as expected

I'm new to using postman to create tests for a simple api. As part of this I want to create a post request, then use the generated id in subsequent Get, Put and Delete tests. Below is how I'm saving the id as a variable (have also saved it in the environment) and my API schema.

pm.test("Status code is 201", function () {
    pm.response.to.have.status(201);
    var jsonData = pm.response.json();
    pm.environment.set('todo2', jsonData.id)
});
{
        "id": "integer",
        "name": "string",
        "isComplete": boolean
    },

But when I try to call my Get request for that generated id using in my header it instead returns everything from my API rather than the specific api which I thought I had saved in the variable. Can anyone help point me in the right direction, not sure where I'm going wrong.

Aucun commentaire:

Enregistrer un commentaire