How to generate Code Snippet from Postman How to generate Code Snippet from Postman

Page content

In this tutorial, we’ll learn how to generate a Code snippet from Postman for HTTP GET, POST, PUT, DELETE requests in various programming languages like C, C#, cURL, Dart, Go, Java, Javascript, NodeJs, Objective-C, PHP, Python, R, Ruby, etc.

Steps to Generate Code Snippet from Postman

You can generate the code snippet from Postman in supported programming languages by following these 5 steps:-

  1. Create an HTTP request in Postman or Open an existing request in Postman
  2. Click on the code icon </> in the right pane. It will open a “Code Snippet” dialog on the right side.
  3. Select the programming language from the dropdown list
  4. Change the code snippet settings such as formatting, indentation, set request timeout, etc. Available settings change based on your programming language selection from the dropdown list.
  5. Select the copy icon to copy the code snippet to your clipboard.
Generate cURL from Postman for HTTP Request

Supported Languages in Postman

Postman is a very powerful tool and can be used to generate code snippets in various languages. Postman supports the following languages and frameworks to generate code snippet, which are available in the dropdown list:-

  1. C# - HttpClient
  2. C# - RestSharp
  3. cURL
  4. Dart - http
  5. Go - Native
  6. HTTP
  7. Java - OkHttp
  8. Java - Unirest
  9. Javascript - Fetch
  10. Javascript - JQuery
  11. Javascript - XHR
  12. C - libcurl
  13. NodeJs - Axios
  14. NodeJs - Native
  15. NodeJs - Request
  16. NodeJs - Unirest
  17. Objective C -NSURLSession
  18. OCaml - Cohttp
  19. PHP - cURL
  20. PHP - Guzzle
  21. PHP - Http_Request2
  22. PHP - pecl_http
  23. PowerShell- RestMethod
  24. Python - http.client
  25. Python - Requests
  26. R - httr
  27. R - RCurl
  28. Ruby - NET::Http
  29. Shell - Httpie
  30. Shell - wget
  31. Swift - URLSession