Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

358
Views
Java: Send GET PUT POST to an external API and get response

I am relatively new to JAVA and am trying to build a back-end application which will call another server where the data is present.

I have to do GET, POST, PUT and PATCH(can live without PATCH) operations to an external server in the intranet. I can hit the exposed service using postman app (using custom header)but want to do the similar action from my Java code, get the output in my Tomcat Server.

I have limitations in modifying dependencies to the POM file or adding jars to the library, so am looking for a solution other than Jersey.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You can use HttpURLConnection (which extends URLConnection) to handle the http requests and these classes are part of JDK itself so you don't need any external jar files, I suggest you look here for basics on these and look here for examples.

Most of the places, I look for provides me the answer for GET. I see some POST too, but my requirement is mainly for PUT.

In order to place PUT, DELETE, etc.. http operations, you can use httpConnectionObj.setRequestMethod("PUT") or httpConnectionObj.setRequestMethod("DELETE") as given in an example here.

about 4 years ago · Santiago Trujillo Report

0

you could set up a simple java.net.Socket instance and implement the calls yourself - then you don't need any dependencies.

http://www.cafeaulait.org/course/week12/22.html

about 4 years ago · Santiago Trujillo Report

0

java.net.HttpURLConnection seems to be the way to go then. This might i.e. be initialized like so: (HttpURLConnection) new URL(url).openConnection()

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!