Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: Function to send request from pre-request script #2205

Closed
1 task done
greg-vstorm opened this issue Mar 25, 2022 · 10 comments
Closed
1 task done

[feature]: Function to send request from pre-request script #2205

greg-vstorm opened this issue Mar 25, 2022 · 10 comments
Labels
feature New feature or request

Comments

@greg-vstorm
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Summary

Postman provides method sendRequest to make AJAX request from pre-request script. For example:

pm.sendRequest({
    url: 'http://example.localhost/sanctum/csrf-cookie',
    method: 'GET'
}, function (error, response, {cookies}) {
    if (!error) {
        pm.environment.set('xsrf-token', cookies.get('XSRF-TOKEN'))
    }
})

This feature is useful when you need to get for example xsrf-token,

Why should this be worked on?

Allow testing API's build with Laravel Scout to get xsrf-token. I think it's much more use cases than this one.

@greg-vstorm greg-vstorm added the feature New feature or request label Mar 25, 2022
@AndrewBastin
Copy link
Member

Thank you for reporting.

We will consider this during the planned revamp of the Scripting System.

@wakeupmh
Copy link

Send request is a missing great feature, please, can you priorize this? 🥺
@AndrewBastin

@AndrewBastin
Copy link
Member

Yup, I am working on a solution for this, stay tuned!

@987Nabil
Copy link

987Nabil commented Aug 5, 2022

@AndrewBastin Any news on this?

@lslavuj
Copy link

lslavuj commented Oct 19, 2022

@AndrewBastin Any news?

@AndrewBastin
Copy link
Member

Please discuss about this in the RFC discussion #2292 for the scripting API revamp.

We are working on a scripting API revamp to support for more complex use cases.

@lathindu1
Copy link

Any update guys. can we get CSRF token in Pre-request scripts now ? We really need it's to test Laravel

@laDanz
Copy link

laDanz commented Nov 7, 2023

Still waiting for this, would really improve my user experience...
I guess it should not be closed, even if it is mentioned on #2292 ?
All other mentioned features on #2292 are not closed...

@bforbis
Copy link

bforbis commented Nov 16, 2023

Would like to add my +1 support for this feature, as it is making it difficult for me to migrate from Postman.

My Use Case: A pre-request script that handles creation of OAuth 2.0 client_credentials grant access token before the request, then stores both the access token and expiration in environment variables.

I have been using this in postman before Postman even added OAuth 2 support, and it's a great way to get around the lack of Hoppscotch support for OAuth 2.0 client_credentials grant (see #874)

It would be really great if these pre-request scripts could then be stored at the collection level and shared.

@nandi95
Copy link

nandi95 commented Apr 25, 2024

Why was this issue closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants