Cheerful Curmudgeon

A complete lack of ideas and the power to express them.

  • Home
  • About Me
    • Art Zemon’s PGP Key
    • Privacy Policy
  • Bede BD-4C
    • Hall of Fame
  • Piper Arrow

Using the JetBrains PhpStorm HTTP REST Client

September 21, 2018 Art Zemon

I’ll admit it: I have previously tried and failed to get the new HTTP REST client in JetBrains PhpStorm to do what I wanted, especially with POST requests and file uploads. This morning, the stars aligned properly and my magic beans sprouted and life is beautiful.

Here is the code. It does a POST call with three form fields, api_key, max_to_ban, and testing. It also has a file upload field. The filename presented to the server is “customers.csv”. The contents of the file on my workstation are read from /home/azemon/Desktop/customers.csv.

POST http://localhost:8080/import/import_users
Accept: application/json
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=WebAppBoundary

--WebAppBoundary
Content-Disposition: form-data; name="api_key"
Content-Type: text/plain

kzce06oenUoTYorFQ7fEXA**

--WebAppBoundary
Content-Disposition: form-data; name="max_to_ban"
Content-Type: text/plain

0

--WebAppBoundary
Content-Disposition: form-data; name="testing"
Content-Type: text/plain

1

--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="customers.csv"
Content-Type: text/plain

< /home/azemon/Desktop/customers.csv

--WebAppBoundary--


###

It is kind of verbose, so typing it all the first time was tedious. On the other hand, changes are trivial because it is just text and easy for me to edit. When I run this, PhpStorm pops open the Run pane and I see this:

POST http://localhost:8080/import/import_users

HTTP/1.1 200 OK
Date: Fri, 21 Sep 2018 17:38:46 GMT
Server: Apache/2.4.34 (Ubuntu)
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'self';   connect-src 'self' https://www.google-analytics.com;   script-src 'self' www.google-analytics.com 'unsafe-inline' 'unsafe-eval';   style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; frame-src 'self' www.youtube.com;   img-src * data: blob: filesystem:; media-src *;   font-src 'self' https://fonts.gstatic.com;
Vary: Origin
Access-Control-Allow-Headers: <snip>
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json

{
  "error": "<snip>",
  "code": 500,
  "success": 0
}

Response code: 200 (OK); Time: 1205ms; Content length: 82 bytes

 

Software

Recent Posts

  • Stretching a Photo April 21, 2025
  • There are Elephants in the Room April 10, 2025
  • Let’s Eliminate Real WFA April 1, 2025
  • Thumb Wrist Neck Waist Height March 18, 2025
  • Avoid Targeted Advertisements February 5, 2025

About Art Zemon

Omni-curious geek. Husband. Father. Airplane builder & pilot. Bicyclist. Photographer. Computer engineer.

Comments

  1. Ed Greenberg says

    September 24, 2018 at 9:58 am

    I’ve been using Postman. My main objection to it is that it takes up a bunch of resources, since it’s written in node (javascript.) I like that it saves every one of my transactions so I can go back, pull one up, modify it and run it again.

Categories

  • Aviation (261)
    • Bede BD-4C (174)
    • Soaring (5)
  • Bicycling (37)
    • St. Louis to Atlanta (8)
    • St. Peters to Minneapolis (18)
  • Business (48)
  • Cabbages & Kings (24)
  • Communicating (37)
  • Ecology (21)
  • Economy (8)
  • Family (35)
  • Finding the Good (43)
  • Fun (188)
    • Six Word Stories (8)
  • Gardening (5)
  • Genealogy (5)
  • Government (35)
  • Health (67)
  • Judaism (10)
  • Men (12)
  • Mideast (5)
  • Movies (8)
  • Philosophy (15)
  • Photography (27)
  • Rants & Raves (103)
  • Recommendations (35)
  • Safety (37)
  • Science (22)
    • Biology (7)
    • Physics (7)
    • Pyschology (3)
  • Technology (195)
    • eBooks (7)
    • Internet (66)
    • Software (63)
    • VOIP (5)
  • Travel (43)
  • Tzedakah (12)
  • Women (5)

You Will Also Like

  • Art Zemon's Genealogy
  • Art Zemon's Photos
  • Mastodon @babka.social
  • Mastodon @raphus.social

Search

#DonorForLife

6 gallon blood donor badge
#DonorForLife - Give Blood - Save Lives

Archives

Copyright © 2025 · Daily Dish Pro Theme on Genesis Framework · WordPress · Log in