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 7840083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:39:11+00:00 2026-06-02T15:39:11+00:00

I have a working json service which looks like this: @POST @Path(/{id}/query) @Consumes(MediaType.APPLICATION_JSON) @Produces(JSON)

  • 0

I have a working json service which looks like this:

@POST
@Path("/{id}/query")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(JSON)
public ListWrapper query(@Context SecurityContext sc, @PathParam("id") Integer projectId, Query searchQuery) {
    ...
    return result
}

The query object looks like this and when posting a json representation of that Query object it works out nice.

@XmlRootElement
public class Query {
    Integer id;
    String query;
    ... // Getters and Setters etc..
}

Now I want to fill that object from a client and use Jersey client to post that Query object to the service and get an JSONObject as a result. My understanding is that it could be done without converting it to a json object first and then posted as a String.

I have tried something like this but I think I miss something.

public static JSONObject query(Query searchQuery){
    String url = baseUrl + "project/"+searchQuery.getProjectId() +"/query";
    WebResource webResource = client.resource(url);
    webResource.entity(searchQuery, MediaType.APPLICATION_JSON_TYPE);
    JSONObject response = webResource.post(JSONObject.class);
    return response;
}

I’m using Jersey 1.12.

Any help or pointer in the right direction would be much 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-06-02T15:39:13+00:00Added an answer on June 2, 2026 at 3:39 pm

    If your web-service produces a JSON you must handle that in your client by using an accept() method:

    ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(searchQuery, MediaType.APPLICATION_JSON);
    ListWrapper listWrapper = response.getEntity(ListWrapper.class);
    

    Try this and give your results.

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

Sidebar

Related Questions

I have been working on a json decode issue (which I have already had
I have a JSON data store used for a combobox selection which is working
i have a working example which uses this url http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=jQuery16201154390876987067_1314382298849&tags=cat&tagmode=any&format=json&_=1314382298856 which gives me this
I'm working on implementing a JSON RPC connection over TCP/IP and I have one
I have a third party library which I finally have working within my MonoTouch
Have been working on this question for a couple hours and have come close
I have a ASP.NET web service decorated with System.Web.Script.Services.ScriptService() so it can return json
How can I post JSON objects to a web service, through cURL in php?
I have a working application using Json.NET (newtonsoft) as a custom serializer. Currently I'm
I have a WCF service in an ASP.NET AJAX app that is returning json.

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.