Friday, August 28, 2015

Postman Miscs



Upload a file:
https://github.com/postmanlabs/postman-app-support/issues/1441

http://stackoverflow.com/questions/16015548/tool-for-sending-multipart-form-data-request
Actually Postman can do this. Here is a screenshot
Newer version
enter image description here
Be careful with explicit Content-Type header. Better - do not set it's value, the Postman is smart enough to fill this header for you. BUT, if you want to set the Content-Type: multipart/form-data - do not forget about boudary field.

https://www.getpostman.com/docs/requests

form-data

multipart/form-data is the default encoding a web form uses to transfer data. This simulates filling a form on a website, and submitting it. The form-data editor lets you set key/value pairs (using the key-value editor) for your data. You can attach files to a key as well. Do note that due to restrictions of the HTML5 spec, files are not stored in history or collections. You would have to select the file again at the time of sending a request.
http://blog.getpostman.com/2014/11/15/using-newman-to-run-collections-with-file-post-requests/
Right now, it's not possible to upload files in the collection runner. However, you can use Newman, Postman's command-line companion, as a workaround:
https://www.getpostman.com/docs/run_file_post_requests

https://sixgun.wordpress.com/2013/11/18/testing-cors-with-postman/
https://www.getpostman.com/docs/requests
As the packaged app runs in a sandbox separately from the browser, it can not access cookies set inside the browser. This restriction can also be overcome using the Interceptor extension. Postman routes all requests through the Interceptor, which then uses the browser context to send requests. Cookies set inside the browser are automatically attached to your requests. Read the original blog post on Interceptor.
Once the interceptor is enabled, you can also send cookies from Postman. Just set the "Cookie" header, and the cookie will be sent with the request. You can also get access to cookies that are available when the response is returned.
https://github.com/postmanlabs/postman-app-support/issues/391
If the Interceptor is not enabled, you can check the exact request payload in the Network tab of the DevTools window - http://blog.getpostman.com/2015/06/13/debugging-postman-requests/

Using the request builder
If you are making requests from the main Postman window with the Interceptor disabled, read on. You can right click on the main Postman window > Inspect element. In the Network tab, you’ll be able to see the request when you click the Send button. Clicking on the request in the Network tab will show you the response payload.

Sending requests with the Interceptor enabled
Postman, being a Chrome application, has certain restrictions. For example, you cannot set Cookies while making a request. There’s a companion extension called the Postman Interceptor that acts as a middleman and lets you add cookies from within Postman! When the Interceptor is enabled, the actual HTTP request is made from the Interceptor, and not from Postman.
You can head to chrome://extensions, enable ‘Developer Mode’, and search for the Interceptor. Click the “Inspect views: background.html” link to open DevTools. You should see the requests and responses in the Interceptor’s DevTools window when you make requests through Postman.
Access cookies and restricted headers
Install Postman Interceptor

And enable the interceptor in postman app – at the top toolbar

Reference:


http://blog.getpostman.com/2014/02/20/using-variables-inside-postman-and-collection-runner/
{{my_variable_name}}
Variables can be used almost everywhere inside Postman. They are available inside:

1. URL
2. URL params
3. Header values
4. form-data/url-encoded values
5. Raw body content
6. Helper fields

https://www.getpostman.com/docs/environments
Dynamic variables

{{$guid}}: Adds a v4 style guid
{{$timestamp}}: Adds the current timestamp
{{$randomInt}}: Adds a random integer between 0 and 1000

Disable certificate check in newman:
newman -kl -c collection.json -e local.json

https://github.com/postmanlabs/postman-app-support/wiki/Postman-Proxy
Due to these restrictions the following headers are blocked:
Origin
Referer

These restrictions probably make sense for protecting the user agent but make testing API backends difficult.

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts