Jump to content
bernhard

How to use Postman to test AJAX requests

Recommended Posts

This is actually very easy but might be interesting for someone anyhow (and I post it here as a reminder for myself).

You can use Postman (https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=de) to send requests to your ProcessWire installation and test request answers. The problem is that $config->ajax will always return FALSE.

To make the $config->ajax work properly you just need to add this key-value-pair to your requests:

key: X-Requested-With
value: XMLHttpRequest

5ac4d40495439_2018-04-0415_32_20-Postman.png.d77a0357a5d2a5fe72561695e268e08a.png

Happy AJAXing :)

PS: This also works inside the admin, see post 3 :)

  • Like 7
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for the tip.

btw - PHPStorm has a REST client tool built-in (this is more of a reminder / info for other PHPStorm users - it's such a massive IDE that handy features like these can be easily missed)

  • Like 2

Share this post


Link to post
Share on other sites

You can even use it inside the backend:

  • Install Postman Interceptor extension
  • Activate the extension in the browser and in the postman app
  • Go to your desired admin page (eg /page/edit/?id=123)
  • The request will show up in the history and you can modify it to your needs

I'm doing a die('test') here in the admin, with tracy installed, of course O0

5ac4e00dc2a25_2018-04-0416_23_12-Postman.thumb.png.bab5af2662c3d7043fd5fec9f2164923.png

  • Like 3

Share this post


Link to post
Share on other sites
4 hours ago, bernhard said:

and I post it here as a reminder for myself

Hehe. The PW forum is a nice snippets manager and knowledge base for free :P 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...