Skip to content

Read external files in pre-tests and tests requests #7210

Open
@ymeunier

Description

@ymeunier

Hi,
I'm developping a postman collection for do a regression-test on my API.
I'm validating all my responses schemes with tv4.
I run some similar queries whose answers are usually very close. Therefore the validation schemes are the same.
How can I outsource my schemes in order to simplify my collection and simplify the corrections?

Best Regards,
Yann

Activity

shamasis

shamasis commented on Aug 30, 2019

@shamasis
Member

Indeed we are considering an api to read files in away similar to how files are read for request body via a working directory.

BidyutJBorah

BidyutJBorah commented on Aug 12, 2020

@BidyutJBorah

Any updates on this feature?

deepayadav06

deepayadav06 commented on Sep 23, 2020

@deepayadav06

Hi @shamasis Any updates on this feature, We use GraphQL where we have lots of mutations and queries against which automated tests are written, But we are struggling at the moment to deal with last and complex data sets. Thanks

zekikaraca

zekikaraca commented on Oct 2, 2020

@zekikaraca

Any progress on this feature guys? An update would be great. I would love to be able to use this in Postman.

fionayang99

fionayang99 commented on Oct 24, 2020

@fionayang99

This will be a great feature to have, any updates?

sanster9292

sanster9292 commented on Feb 12, 2021

@sanster9292

Any updates on this issue??

froyo2

froyo2 commented on Feb 18, 2021

@froyo2

I need to calculate the file md5 before calling the api, so I really need this feature, any updates on this issue?

mrkprdo

mrkprdo commented on Feb 19, 2021

@mrkprdo

If this feature is going to be implemented, READ/WRITE External file, I'm going to devote my devops career to use Postman, till something will surpass its functionality.

But for now, sticking to native testing frameworks, currently using Rest-Assured.

Chris-Loughnane

Chris-Loughnane commented on Feb 23, 2021

@Chris-Loughnane

... why is this still not available? I have found posts from 5~6 years ago with people asking for it. I'm tired of generating JWT tokens in my CLI and then manually updating my postman environment. Let us access system environment variables or let us load from a file.

phalverson

phalverson commented on Feb 25, 2021

@phalverson

Waiting for this as well, I want to read AWS authorization credentials (key, secret, session token) from a local .aws/credentials file that changes very frequently (SSO timeouts), instead of constantly having to copy and paste values into workspace environment variables.

jiteshk11

jiteshk11 commented on Mar 11, 2021

@jiteshk11

Waiting for this feature for long time now!!!!

shamasis

shamasis commented on Mar 16, 2021

@shamasis
Member

Newman and Postman App shares the same core code. As such these become exponentially difficult to build.

  • direct access to OS environment variables seems something that will not fit the abstractions

  • reading files from a repository / specified folder is something we need to align on. This is already available in Postman app (not exactly the feature discussed in this thread, but the ability store file in a working directory and use it in file upload APIs) we need to adopt and perhaps extend the same.

I don't see these come together soon a bit of more groundwork is needed how external files fit into the whole API lifecycle.

Would love to continue this discussion around the bigger picture here and know more around what adds up.

rothrock

rothrock commented on May 5, 2021

@rothrock

Really need to read a local file.

Creedzy

Creedzy commented on Jul 29, 2021

@Creedzy

It's been 8 years since it was requested in another ticket. Just saying.

igorbljahhin

igorbljahhin commented on Aug 4, 2021

@igorbljahhin

I also would like to read local files in pre-request scripts. In our project we use postman/newman to upload website provisioning data to STAGE/PROD environments. At the moment we successfully uploading data from CSV files. Now I would like to upload text files also.

bencpeters

bencpeters commented on Feb 7, 2022

@bencpeters

I have the same use-case as @phalverson (reading AWS credentials from the system file). This really doesn't seem like it should be such a difficult ask!

Camble

Camble commented on Mar 7, 2022

@Camble

Can't believe this really isn't implemented.

Penumbra69

Penumbra69 commented on Mar 31, 2022

@Penumbra69

All I want to do is make a signed JWT using the current date, which means needing to either read a file, or use an external module. The modules which support signing JWT's in Javascript land do not publish minified/umd versions of their code, so importing via the unpakd.com method is not going to work. I need to be able to load a module which can then do the work of creating / signing + inserting CURRENT TIME in my JWT payloads.

Right now I have a (very janky) approach by using browserify to "modularize" all the code and dependencies of the module, and then pasting that minified code to a freakin' environment variable so I can eval() it for use.. Similar to your unpakd.com janky workaround. I've still had to hand-edit some of that code because the "this" in the module loader and the "this" in the postman pre-req script are not the same "this" -- regardless of what your example shows. (console.log(this) doesn't lie.)

So what we need are either:
A) Your team to add token parsing/ decoding/ verifying/ creating code into your Postman modules that you insert into the codebase, or a way to properly load them.
B) A way to load schema / test data / WHATEVER WE NEED from a safe space (Like, say /Users/my_user/Postman/files -- which you already condition for use) so we can load modules / code / test data / WHATEVER IS REQUIRED by our enterprise to properly pre-condition a request.

Failing either of these fails this product at being capable of working with modern API's that require oAuth / OIDC / Auth0 style interactions.

Q.E.D.

erhhung

erhhung commented on Apr 4, 2022

@erhhung

@Penumbra69 While this reply doesn't address Postman's underlying deficiency, the technique that I've been using to load external modules into pre-request scripts might help you from having to squeeze minified code into an environment variable:
https://gist.github.com/erhhung/4d8884c014350364791587425259c8ea

Since Postman does support invoking additional arbitrary requests in the pre-request script, I've also thought about—but never needed to implement—loading external files by running a local http-server (CLI one-liner) that serves the files I need, and making requests to http://localhost/my_data.json. Of course you can also run any local HTTP server that supports shell-based CGI scripts so you can perform any task you need.

aklef

aklef commented on May 19, 2023

@aklef

I have a test case just now where I need to automate a comparison to an expected result from some process' network folder dump... there's just no easy way currently with Postman, bummed

Darkona

Darkona commented on Jun 22, 2023

@Darkona

For those in the future to stumble upon this thread, I made a little utility in python that can ease some of the pains for the lack of the feature. Please take a look at: https://github.com/Darkona/Tardigrade

cheers

humbienri

humbienri commented on Sep 26, 2023

@humbienri

Hello all,

Kinda new here and been stumbling through a few of these issues here on Github regarding this "external files" matter. I've now seen it mentioned a couple of times, including on StackOverflow, the idea of setting up your local HTTP server to be able to sneak in the file. However, I do wonder how that would work once you have to integrate your API tests into a CI/CD scenario? I'm not that technical but it seems to me that's a no go?

Another thing that comes to mind is that if you are that technical to be setting up local servers and such...then why bother automating your tests using a tool like Postman, instead of just going straight up programmatically w/ something like axios/supertest/got etc.?

Thanks for the insights folks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @shamasis@Camble@humbienri@aklef@igorbljahhin

      Issue actions

        Read external files in pre-tests and tests requests · Issue #7210 · postmanlabs/postman-app-support