# Automate Rest API using java with postman

**URL:** <https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954>\
**Category:** Help Hub\
**Tags:** tests, collections\
**Created:** [November 12, 2019, 11:23am UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954 "2019-11-12T11:23:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bibhuTest12](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@bibhuTest12](https://community.postman.com/u/bibhuTest12)\
**Post date:** [November 12, 2019, 11:23am UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/1 "2019-11-12T11:23:40Z")

</div>

Hi All,

I am new to API testing.I am trying to Automate the API using postan but dont know how to automate the API with postman using java.Please let me know how to process in this.  
I googled it but didn’t found a solution.

Hope I will find my answer here and I will very thankfull to you guys.

Thanks & regards  
Bibhu Pandey

---

<div class="post-metadata">

**Author:** ![suraj.purohit](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@suraj.purohit](https://community.postman.com/u/suraj.purohit)\
**Post date:** [November 12, 2019, 12:13pm UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/2 "2019-11-12T12:13:06Z")

</div>

Hi @bibhuTest12,

Welcome to the community. 👋

Automating your API tests with Postman is possible using JavaScript. It is the only supported language to write per-request and test scripts in Postman.

**Here are some useful resources to get started:**

**# How write API Tests with Postman: (Valentin Despa)**

- Part 1: [https://www.youtube.com/watch?v=Qlvbc6kIBOk](https://www.youtube.com/watch?v=Qlvbc6kIBOk)
- Part 2: [https://www.youtube.com/watch?v=AgBg0CMknfI](https://www.youtube.com/watch?v=AgBg0CMknfI)
- Part 3: [https://www.youtube.com/watch?v=iPJCutFXzQE](https://www.youtube.com/watch?v=iPJCutFXzQE)

**# Intro to Postman:**

- [https://www.youtube.com/watch?v=7E60ZttwIpY&list=PLM-7VG-sgbtAgGq\_pef5y\_ruIUBPpUgNJ](https://www.youtube.com/watch?v=7E60ZttwIpY&list=PLM-7VG-sgbtAgGq_pef5y_ruIUBPpUgNJ)

**# Automate test runs using Newman:**

- [https://www.youtube.com/watch?v=lar1gzDbY78](https://www.youtube.com/watch?v=lar1gzDbY78)

**# Articles:**

- [Writing Automated API Tests Using Postman For Beginners: Step 1 — The Basics & Making Our First GET Request | by Faz540 | Medium](https://medium.com/@faz540/writing-automated-api-tests-using-postman-for-beginners-step-1-the-basics-making-our-first-get-cef922e5e418)
- [From manual to automated testing: The roadblocks and the journey | by Kaustav Das Modak | Better Practices | Medium](https://medium.com/better-practices/from-manual-to-automated-testing-the-roadblocks-and-the-journey-6333dfacc5ae)

---

<div class="post-metadata">

**Author:** ![bibhuTest12](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@bibhuTest12](https://community.postman.com/u/bibhuTest12)\
**Post date:** [November 12, 2019, 2:19pm UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/3 "2019-11-12T14:19:52Z")

</div>

Hey Suraj,

Thanks for sharing the helpfull content.  
Thanks a lot.

Regards  
Bibhu Pandey

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 12, 2019, 4:30pm UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/4 "2019-11-12T16:30:40Z")

</div>

Hi @bibhuTest12,

Looks like you are trying to use Postman JavaScript tools to do some automation. I’d recommend the above videos and you can also look at this pre request and test script video I made:

Postman Pre Request and Test Scripts Tutorial - Introduction to Postman [https://youtu.be/NA2nfftMC5E](https://youtu.be/NA2nfftMC5E)

Additionally, you can watch the whole intro series I made for a good basis on Postman.

Introduction to Postman Tutorial [https://www.youtube.com/playlist?list=PLtnFhV9xWljfvww1P\_fNgb0cnA4H-zmZQ](https://www.youtube.com/playlist?list=PLtnFhV9xWljfvww1P_fNgb0cnA4H-zmZQ)

Now if you’re trying to use Java to run Postman requests, you can do so via Postman’s api and building requests in Java from Postman. Or you can use Newman that you can kick off from your Java code.

If you can elaborate a bit more on how you’re trying to run the automation, I’d be more than happy to provide more details 😊.

Regards,  
Orest

---

<div class="post-metadata">

**Author:** ![shubhDcoder](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@shubhDcoder](https://community.postman.com/u/shubhDcoder)\
**Post date:** [March 16, 2022, 8:15am UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/5 "2022-03-16T08:15:16Z")

</div>

Hello,  
I have a use case, I hope you can help me here.

We are using karate framework for API testing. As this is built on top of Cucumber, it requires creating feature files. Everything was working well.

Now, we had a requirement where we need to run the postman collections as it is. Karate supports generating the feature files on the basis of collection provided, but it skips the tests and pre-request scripts.

We are thinking to revise our approach here,  
Requirements are.

1. need to run postman collection.
2. all the tests and pre-requests script should run and if any assertion fails, it should report it back.
3. the reporting should be more detailed oriented.

I have come across newman and seems like a good fit, but can we generate cucumber/testng/junit type of reports with it ?

Can we use java based solution for this ? Installing the newman package and running it in using Runtime library, is this a good practice to have in project ?

As we are taking the requirement 1) as the topmost priority and this is directly connected with the postman, what alternates can we suggest for this requirement ?

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [March 21, 2022, 1:44am UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/6 "2022-03-21T01:44:08Z")

</div>

Welcome to the community @shubhDcoder 👏

To be honest, I am not that familiar with this. If you definitely need to run the postman collection, and automatically running tests, then I certainly recommend using newman.

> [@shubhDcoder](#):
>
> I have come across newman and seems like a good fit, but can we generate cucumber/testng/junit type of reports with it ?

Doing a quick search, I couldnt seem to find specific cucumber/junit reports, but @danny-dainton wrote a great HTML reporter that you may find useful.

> **[GitHub - DannyDainton/newman-reporter-htmlextra: A HTML reporter for...](https://github.com/DannyDainton/newman-reporter-htmlextra)**
>
> A HTML reporter for Postman's Command Line Runner, Newman. Includes Non Aggregated Runs broken down by Iterations, Skipped Tests, Console Logs and the handlebars helpers module for better cust...

> [@shubhDcoder](#):
>
> Can we use java based solution for this ? Installing the newman package and running it in using Runtime library, is this a good practice to have in project ?

I am not certain of what you mean here, if you are saying to invoke Newman via Java code, I don’t see a problem with that. However, it might be better to use CI/CD pipeline tools like Jenkins that can automatically run these tests after a build, when configured to do so.

As for other reporting alternatives, I’m not sure what else there really is, but there are other packages out there that do reporting.

Now, I’m if Cucumber / junit can import test results, then you could, in theory write your own reporter based on the output of newman (as @danny-dainton did), so that it matches the expected input for Cucumber / junit, and simply upload the resulting file to cucumber / junit for recording test results.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![gopalakshintala](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gopalakshintala/32/31491_2.png) [@gopalakshintala](https://community.postman.com/u/gopalakshintala)\
**Post date:** [January 31, 2025, 11:23am UTC](https://community.postman.com/t/automate-rest-api-using-java-with-postman/8954/7 "2025-01-31T11:23:02Z")

</div>

Checkout this free and Open-source JVM library to write API automation in Java/Kotlin using Postman templates: [salesforce-misc/ReVoman: A Template-driven API automation tool for JVM (Java/Kotlin)](https://github.com/salesforce-misc/ReVoman)
