Skip to main content

Have K2 specify null values in JSON payload rather than leaving out the property

  • 21 November 2022
  • 0 replies
  • 19 views

Hi All,

I'm integrating with a Web Service provided by a 3d party and I don't have control over the web service.

They provided a swagger file and an extract of the swagger for the method in question is below as an example.

There are some optional fields but the Web Service has a requirement that the field needs to be specified with a null value.

When I don't specify a value for one of the fields from the K2 smartobject (or even pass scnull), K2 does not include the property in the payload instead of specifying it as null, see below.

Is there a way I can force K2 to specify the property in the JSON payload with a null value rather than leaving it out?

 

Swagger:

 

"AddWorkflowStepV2Request": { "title": "AddWorkflowStepV2Request", "description": "#### Add a step to the Workflow request.", "type": "object", "properties": { "ActionField": { "description": "#### Is the action taken by a user in a workflow on this step.`", "type": "integer", "format": "int32", "enum": : "0", "1", "2" ] }, "CellField": { "description": "Mobile number of participant", "type": "string", "minLength": 1 }, "DocIDField": { "description": "Document ID field.", "example": "2147483647", "type": "string", "minLength": 1 }, "EmailField": { "description": "Participant email address", "example": "email@domain.com", "type": "string", "minLength": 1 }, "FirstNameField": { "description": "Participant firstname.", "example": "John", "type": "string", "minLength": 1 }, "LanguageCodeField": { "description": "Participant 2 Digit ISO Language Code `en = English`", "example": "EN", "type": "string", "minLength": 1 }, "LastNameField": { "description": "Participant last name.", "example": "Smith", "type": "string", "minLength": 1 }, "ProxyAllowedField": { "description": "#### Determines whether or not the signer can nominate someone else`", "type": "integer", "format": "int32", "enum": : "0", "1" ] }, "TokenField": { "$ref": "#/definitions/TokenField" } }, "required": : "ActionField", "DocIDField", "EmailField", "FirstNameField", "LastNameField", "ProxyAllowedField", "TokenField" ] }

 

 

Expected payload with null values

 

{ "ActionField": 0, "CellField": null, "DocIDField": "284751", "EmailField": "you@email.com", "FirstNameField": "Joe", "LanguageCodeField": "en", "LastNameField": "Soap", "ProxyAllowedField": 0, "TokenField": { "TokenExpiryField": "/Date(1668792870000+0000)/", "TokenField": "quyzvd" } }

 

 

What K2 generates (Notice the Cellfield is not specified)

 

{ "ActionField": 0, "DocIDField": "284751", "EmailField": "you@email.com", "FirstNameField": "Joe", "LanguageCodeField": "en", "LastNameField": "Soap", "ProxyAllowedField": 0, "TokenField": { "TokenExpiryField": "/Date(1668792870000+0000)/", "TokenField": "quyzvd" } }

 

 

Be the first to reply!

Reply