Rest Integration Action throws "class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')"

Cory B
Kilo Expert

I created an Action in flow designer that sends a Rest request to my server.  I used the Rest integration to create this action.  When I try to pass json that was created from a previous Action and then I test the workflow I get the following error "class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')".  If I test the Rest Action independently and pass the same exact json payload it works fine.  Maybe Im not passing the variable in correctly or my previous Action that builds the json has something wrong with it.  Please see my included screen shots below.

 

Picture of Rest Action inputs

find_real_file.png

 

Picture of Rest Action step

find_real_file.png

 

Pictures of the Action that builds the json

find_real_file.png

find_real_file.png

 

 

Pictures of the Error that occurs during Rest Action when the workflow is tested

find_real_file.png

find_real_file.png

find_real_file.png

 

 

Pictures of when the Rest Action is tested independently and is passed the same exact json it works.

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @Cory B 

in your REST step, you have dragged the JSON-based payload into the request body field and this cannot work. FlowDesigner needs a String there and does not know what part of your JSON object should be inserted. 

If you want to send the complete JSON payload in a serialized form you have to call JSON.stringify() anywhere. For example you could build another action which does that job.

Kind regards
Maik

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

View solution in original post

8 REPLIES 8

Maik Skoddow
Tera Patron
Tera Patron

Hi @Cory B 

in your REST step, you have dragged the JSON-based payload into the request body field and this cannot work. FlowDesigner needs a String there and does not know what part of your JSON object should be inserted. 

If you want to send the complete JSON payload in a serialized form you have to call JSON.stringify() anywhere. For example you could build another action which does that job.

Kind regards
Maik

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Thanks Maik. Let me test it out. So you saying just call JSON.stringify on the entire payload before passing it to the Rest Step/action?

That worked. Thank you! Its just odd because on the input of the action if you make it a String you would think it would convert it to a String or throw an error if the value you something other than a String but it doesn't...

Hi @Cory B 

Did my reply answer your question?

If so, please mark the appropriate response as "correct" so that the question will appear as resolved for other users who may have a similar question in the future.

If not, please tell me what you are still missing!

Many thanks & kind regards
Maik