Formulating a JSON body in the correct format for submission to an existing API endpoint.

Hi,

 

Scenario:

I would like to formulate a JSON body for an HTTP POST request method in an expression rule, so that my API endpoint (called via an integration object) can correctly recognise the parameters that it should be taking to change entries in a database.

 

I have a process model, which looks like this:

 

Currently expression in the Body section of my Integration object looks like this:

 

a!forEach(items: ri!bulkUpdateInvoiceIds, expression: a!toJson({fv!item}))

My rule input is of a custom type that has EventId and ClientInvoiceNumber as type int.

 

This is the test JSON object that I am passing in to test my Body expression:

 

{
    {EventId: 1,
    ClientInvoiceNumber: 123},
    {EventId: 2,
    ClientInvoiceNumber: 12}
}

 

Currently the API call writes '0' into the row of the database, where I am expecting it to write the the ClientInvoiceNumber, based on the given EventId. This is strange, as the objects seem to be getting passed into the through correctly, as the request returns a 204 and looks to be sent as the following:

[{"EventId":1,"ClientInvoiceNumber":123}]; [{"EventId":2,"ClientInvoiceNumber":12}]

 

I have tested my API endpoint locally and it works perfectly via Postman - updating DB record for ClientInvoiceId, where the EventId is equal to one that is passed in. I think the issue lays in the expression rule that I am using to formulate the JSON body to be passed to the API endpoint.

 

Does anyone have any suggestions?

 

Thanks,

  Discussion posts and replies are publicly visible