Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:06:42+00:00 2026-05-28T18:06:42+00:00

I have a server and a client. I am using Spring to map http

  • 0

I have a server and a client. I am using Spring to map http requests on the server and RestTemplate to make requests to the server.

Server code looks like this:

@RequestMapping (value="/someEndPoint", method = RequestMethod.POST)
@ResponseBody
public String configureSettings(
@RequestParam(required=false) Integer param1,
@RequestParam(required=false) Long param2,
@RequestBody String body)
{

if(param1 != null)
// do something

if(body not empty or null)
//do something

} 

Client side:

String postUrl = "http://myhost:8080/someEndPoint?param1=val1"
restTemplate.postForLocation(postUrl, null);

This works in that the correct action is triggered on the server side from param1
however, the body of the request also contains:
param1=val1
The request body when it is set it will json so all I want is to be able to set other parameters without setting the body.
I know I am using the restTemplate incorrectly so any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:06:44+00:00Added an answer on May 28, 2026 at 6:06 pm

    You are doing an HTTP POST, but you are not providing an object to put POSTed. Spring’s RestTemplate is trying to figure out what you want to POST, so it looks and sees that the query string of the url has something, so it tries to use that.

    Do not add a query string to a POST, just provide the object that you want to POST.

    String postUrl = "http://myhost:8080/someEndPoint"
    restTemplate.postForLocation(postUrl, new ParamModel("val1"));
    

    The book Spring in Action (3rd edition) covers RestTemplate (and REST in general) pretty well. I would recommend taking a look at it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Flex client and a server that is using the Spring/Blazeds project.
I have implemented a web service with server and client authentication using keytool. The
I have a client-server application written in Java using CORBA for the communication. The
I`m writing client-server app for windows using WinSock and I have class for server.
I have no experience with web services. Historically I've built client-server systems using proprietary
Hey gang. I have just written a client and server in C++ using sys/socket.
I have a .NET client application that needs to communicate with a server using
Hi all I have created server and client using blackberry java programming ,but i
I have a client app that communicates to the spring server with REST type
I would like to send large files from the server to the client using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.