jsonazure-synapseazure-spring-cloud

Synapse Web Activity could be changing datatime2 format


I have a Web Activity to send a POST request to an API created in Azure Spring Apps. The body is made out of the result of a previous query, in JSON format. The Web Activity sends the request properly but returns error 400.

The error logs shows his:

2025-04-14 13:37:54.582 WARN 1 --- [nio-1025-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.time.OffsetDateTime from String "2025-04-13T16:34:24.938": Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException) Text '2025-04-13T16:34:24.938' could not be parsed at index 23; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.time.OffsetDateTime from String "2025-04-13T16:34:24.938": Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException) Text '2025-04-13T16:34:24.938' could not be parsed at index 23 at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 306] (through reference chain: java.util.ArrayList[0]->com.core.model.Transaction["transactionDTime"])]

Inspecting the input of the Web Activity in Synapse, I see the transactionDTime value is correct as shown here:

{
    "method": "POST",
    "headers": {
        "Content-Type": "application/json",
        "Authorization": "Bearer AASDFASDFADFADF...",
        "Accept": "*/*"
    },
    "url": "https://azure.spring.apps.domain.azuremicroservices.io/api/transaction/bulk",
    "connectVia": {
        "referenceName": "AutoResolveIntegrationRuntime",
        "type": "IntegrationRuntimeReference"
    },
    "body": [
        {
            "description": "payload description",
            "transactionDTime": "2025-04-13T16:34:24.938Z",
            "amount": 10,
            "initialBalanceAmount": 100.00,
            "currencyCode": "USD",
        }
    ]
}

The difference I see is that in the input Json, the datetime value has the trailing Z for the offset datetime, however, in the error reported in the log, there is no trailing Z for UTC. My best guess is that this is triggering the error.

In fact, If I use the same body in my postman collection, the API endpoint runs ok and performs the expected activities. That-s how I think the problem is not necessarily in the body of the input in the WebActivity, but after that. I tried removing the Z at the end of the date string, using Postman, and got the same error.

My question is how can I prevent the Web Activity to alter the datetime literal?

UPDATE If I set the body of the Web Activity equals to the body text, it works ok. the problem is when I set the body to an expression, like @variables('currentBatch').

What I did was copying the body that appears in the web Activity Input and pasting it in the body text box of the Web Activity

UPDATE 2

This is the configuration of the WebActivity. If I put the body of the input directly on the body of this form, it works. But otherwise, is still throwing the Bad Request.

enter image description here

UPDATE 3

this is the output of the lookup Activity, datetimes appear to be well formatted. As in the input of the web Activity.

{
    "count": 5,
    "value": [
        {
            "description": "SWIFT",
            "transactionDTime": "2025-04-14T22:54:43.75Z",
            "amount": 450,
            "initialBalanceAmount": 1700.00,
            "currencyCode": "USD"
        }
    ]
}

and this one is the output of the Set CurrentBatch Activity

{ "name": "currentBatch", "value": [ { "description": "SWIFT", "transactionDTime": "2025-04-14T22:54:43.75Z", "amount": 4500, "initialBalanceAmount": 1773972.48, "currencyCode": "USD", } ] }


Solution

  • I also have a pipeline which uses below config for POST webACtivity

    WebActivity_POST

    The only change you can make is how you generating date , in my case I am using the stored proc to get the latest run(also it has some additional logic which not required here) and give the date in below format

    `SELECT CONVERT(VARCHAR(50), CAST(GETDATE() AS DATETIMEOFFSET(3)), 127) AS transactiondate`
    --2025-04-15T14:31:49.303Z
    
    

    Also the above screenshot is a sample in actual pipeline I am creating a body expression and assigning it to a variable and use that variable in web activity as shown below

    Set Body

    enter image description here Hope this sort out the issue.