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

117
Views
OPTIONS/HEAD REST API request with Okhttp3

I`m writing some Rest client on Android and I met a problem - I have no idea how to make HEAD and OPTIONS requests.

There are no problems with GET/POST/PUT/DELETE/PATCH requests in OkHttp3, basically they looks like:

        request = new Request.Builder()
                .url(url)
                .headers(headerBuilder.build())
                .post(bodyBuilder.build())
                .build();

And OkHttp3 doesnt provide additional methods like head() or option().

So how can I make HEAD and OPTIONS requests using OkHttp3?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Found answer, may be it will be useful for someone else

OkHttp3 still has method

Builder method(String method, RequestBody body)

So OPTIONS requests looks like

        Request request = new Request.Builder()
                .url(url)
                .headers(headerBuilder.build())
                .method("OPTIONS",requestBody)
                .build();

same for HEAD

about 4 years ago · Santiago Trujillo Report

0

It appears (at least in the current implementation, API 3.12.0), HEAD request can be made just like GET and others:

Request request = new Request.Builder()
                .url(url)
                .head()
                .build();

OPTION still has to be implemented using .method()

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!