code to create payload for rest connector

How can we write a script/code to create dynamic payload in Rest Connector.

I will have a business object in contract as list and then I need to create one payload for this list of information.

 Please suggest asap.

Hi,

There are many ways to achieve this. The easiest one could be to use the provided editor and interpolate the dynamic values in the payload:

{ "name" : "${myBusinessVar.name}" }

When manipulating dynamic lists of objects, you may switch the editor to a Script editor and use the Groovy `JsonGenerator to serialize your business variable into a Json payload:

import groovy.json.JsonGenerator

def generator = new JsonGenerator.Options()
// Exludes technical fields presents in BusinessObjects or field you don’t want to expose to the client
.excludeFieldsByName(‘handler’, ‘persistenceVersion’)
.build()
generator.toJson(yourBusinessVariable)

HTH
Romain

Thanks.