Need help on REST client communicating with remote server

Hi guys,

Projects initial requirements is to create a client to communicate with a REST web service server(remote server) using jersey,

i want to create a CLIENT REQUEST HEADER which contains following parameters in same order.

Request PATTERN:

1)GET(method)
2)URL domain(remote)
3)URL path
4)date field(date and time)
5)access key(public key)
6)accept field(application/xml or application/json)

amateur code:

Client client = Client.create();
WebResource webResource =client.resource(url);

ClientResponse response = webResource.queryParam("Date", timeStamp+" GMT")
.header("Authorization", requestAuthKey)
.accept(MediaType.APPLICATION_XML_TYPE)
.get(ClientResponse.class);


😀

Replies

  • Manish Goyal
    Manish Goyal
    A very nice explanation for your Problem.

    #-Link-Snipped-#

    I don't know anything about this language, but it is clear you are passing request parameters in incorrect way
  • micheal john
    micheal john
    Manish Goyal
    A very nice explanation for your Problem.

    #-Link-Snipped-#

    I don't know anything about this language, but it is clear you are passing request parameters in incorrect way
    MultivaluedMap queryParams = new MultivaluedMapImpl();
    queryParams.add("q", "stuff"); //set parametes for request
    Client client = Client.create(config);
    client.addFilter(new LoggingFilter(System.out));
    WebResource webResource =client.resource(url);
    com.sun.jersey.api.client.WebResource.Builder builder = webResource
    .queryParams(queryParams).header("x-date", timeStamp+" GMT")
    .header("Authorization", requestAuthKey)
    .accept(MediaType.APPLICATION_XML);

    for this i'm getting 500 "internal server error"
  • micheal john
    micheal john
    eclipse_console
  • Manish Goyal
    Manish Goyal
    Try to turn on debug level, it will show you actual error,
  • micheal john
    micheal john
    @#-Link-Snipped-#, i tried debbuging for 2 long days and now i arrived at solution.

    problem was my machine time was not synchronized with the server.

    thanks you
  • Manish Goyal
    Manish Goyal
    Good to hear that, Please share what did you learn from this problem, I mean How did you find this problem that it is something related to sync time between machine time

You are reading an archived discussion.

Related Posts

The latest leaks for Windows Phone 8.1 have come up and this time it’s all amazing features. These would give a relief to Windows Phone users who feel jealous of...
Wondering if it's just me or everyone's getting 500 Internal Server Error on YouTube.com. The error message reads - Sorry, something went wrong. A team of highly trained monkeys has...
Proudly called the world's first NFC-Enabled Desktop PC, the Asus MF70AD is now in India for a price of Rs. 62,000. Running on the Windows 8.1 operating system, ASUS M70AD...
Quote: Parents ever tell you that eating carrots would save you from wearing glasses? Or that sitting too close to the TV could make you go blind? Their advice may...
As announced by Microsoft a few weeks earlier, SkyDrive was renamed to OneDrive. Last year, Microsoft had lost a trademark case for SkyDrive with BskyB, which owns trademark rights to...