-1

I am taking the request parameters from the front-end web app and displaying the result accordingly.

Map<String,Object> requestparms

testObj.setUserId(requestparms.get("userId") == null ? null :requestparms.get("userId").toString());

When I test using the restClient I get the following error :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error incidentId="22854566" correlationId="922f4150-4636-4b94-8ac6-71f8ed1935c1">
    <exceptionMessage>[Ljava.lang.String; incompatible with java.lang.String</exceptionMessage>
</error>

I tried

String userId = String.valueOf(requestparms.get("userId"));
System.out.println("The value of variable is " +userId);

Still the same error.

Can you someone please with help information related to it ?

Thank you in advance, Lucky

4
  • Where are you populating the map? Commented Aug 21, 2013 at 19:21
  • 2
    Seems like a String[] instead of a String. Commented Aug 21, 2013 at 19:21
  • possibly caused by attempting to set a String using an Object. Calling toString() on an object is probably not giving you what you want. Commented Aug 21, 2013 at 19:35
  • @RohitJain The map is populated Map<String,Object> testRequestValues=httprequest.getParameterMap(); TestRequest testRequest=RequestParser.createtestObjectFromRequest(testRequestValues); Commented Aug 21, 2013 at 20:00

1 Answer 1

0

Try typecasting as per below

Map<String,Object> requestparms

testObj.setUserId(requestparms.get("userId") == null ? null:(String)requestparms.get("userId").toString());

Otherwise, may be MAP is not understood by REST client?? SOAP doesn't know how to parse MAP so i believe REST is same....

If this is the issue then try using JSON. It definitely works...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.