Data Action PATCH to /api/v2/users/{id}/phone failed - weird offset issue

It’s choking on timezone offsets again…we’ve got a Data Action attempting a PATCH to /api/v2/users/{id}/phone to update a user’s direct dialing number…the flow is pretty basic, just pulling the number from a screen pop, doing a simple string replace, then hitting the API. The error is a 400 with a message saying “Invalid timezone offset provided”…which is dumb, because the offset is valid…it’s just not in UTC, it’s a local offset. Apparently the API expects UTC, even when the offset is provided…and it’s not documented anywhere. The offset being sent is -05:00.

The documentation states the API expects timezone offsets in UTC format - “Timezone offsets must be specified in UTC”. We ran into this last week. Spun up a quick Lambda to convert the offset before the PATCH, fixed it. Honestly, East Coast latency makes debugging this stuff a pain.

1 Like

That Lambda fix is…fine, I guess. We’ve seen this offset nonsense before - it’s not the UTC thing, it’s the format - needs to be ±HH:MM, not just +HH. Here’s a CloudFormation snippet to force that format in the Lambda - it’s messy, but it works.

Resources:
 MyLambdaFunction:
 Type: AWS::Lambda::Function
 Properties:
 Handler: index.handler
 Code:
 ZipFile: #...
 Environment:
 Variables:
 TIMEZONE_FORMAT: "+%H:%M" # or -%H:%M
1 Like

yeah so is kinda right but the earlier post’s onto something too. it’s not just utc, it’s the format. the api is picky - really picky!! i think it wants leading zeros even if it’s +01:00.

we ran into this a few months back with a similar da - took like 2 hrs to debug, honestly. the sdk doesn’t help much, just spits out the 400.

might be wrong but i’d try formatting the offset as ±HH:MM before you even hit the api. you could do that in the flow itself with some string manipulation, or in the screen pop if that’s where the number’s coming from. the lambda is overkill tbh.

here’s a little groovy script snippet you could drop in a flow action to force the format - it’s rough, don’t judge.

def offset = user.division.timezone.offset // or wherever you're getting the offset from
def formattedOffset = String.format("%+03d:%02d", offset.hours, offset.minutes)
return formattedOffset

could be that the division timezone object gives you something you can work with.

1 Like