0
votes

I am trying to set a payload for HTTP request, but when I set a payload using groovy script, the HTTP request throws an error :

ERROR 2017-04-17 12:24:12,260 [[test].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: ******************************************************************************** Message : Response code 400 mapped as failure. Payload : org.glassfish.grizzly.utils.BufferInputStream@6568a94e Element : /test/processors/1/3 @ test:test.xml:59 (HTTP) Element XML : http:request-builder -------------------------------------------------------------------------------- Root Exception stack trace: org.mule.module.http.internal.request.ResponseValidatorException: Response code 400 mapped as failure.

my groovy code is :

   def values = payload.toString().split('\\|')
   message.setInvocationProperty('oauthBody',values[1]);

And then I am doing set payload with flowVars:

#[flowVars.oauthBody]

If I just put the payload string in set payload like this: It works fine.

#[{'username':'test-admin','password':'Password1#','grant_type':'password','scope':'openid,profile,token,email,org'}]

But when I do it with groovy and flowVars it gives me an error.

Please let me know if I am doing anything wrong.

1

1 Answers

0
votes

When you set your payload from the flowVar, it contains a String.

Your set payload with

#[{'username':'test-admin','password':'Password1#','grant_type':'password','scope':'openid,profile,token,email,org'}]

results in a HashMap.

I don't know how you are calling your http service (GET, POST, ...) and what's on the other side. I am wondering why it works when you send it a HashMap (without converting it to XML or JSON before).