pm.sendRequest synchronous

Context:
I’m trying to use ReportPortal.io and one of its agents (postman-agent) to run my Postman Collections.

The postman-agent does not currently support asynchronous calls inside the tests (which a really require to have) so I’ve been trying to find a solution to this (or a workaround)

I found some “solutions” and tried this one here. But got no luck so far.

Is there a native way to make the pm.sendRequest calls inside Tests synchronous. And if not, how would you guys do it? Is this something that will be released later?

I’ll leave here my code and the solution I tried to implement:

 function getAPIRequest(api,guid)
    {
        var options = {
            method: 'GET',
            url: pm.environment.get("apibaseurl") + '/' + api + '/' + guid,
            header: {
                'Content-Type': 'application/json',
                "X-CustomCredentials": pm.variables.get("token")
              }, json: true
        };
        return options;
    }

    function sendRequest(api,id,property,column) {
      return new Promise(resolve => {
        pm.sendRequest(getAPIRequest(api,id),
          function(err, res) {
             pm.test("AUTO010 - " + property + " reference guid is correct.", function(){
                    pm.expect(res.code).to.eql(200);
            });
            db_value = db_values[column];
            pm.test("AUTO014 -The property " + property + " id match with " + column + "from the database.", function () {pm.expect(res.json().code).to.be.eql(db_value) });
          }
        );
      });
    }

    async function senReq(api,id,property,colum) {
      return await sendRequest(api,id,property,colum);
    }

Thanks in advance :slight_smile: