Passing webhook integer variable into makeApiCall JSON body for Google Ads API

:bullseye: What is your goal?

Hi Make community,
I’m building a scenario that creates Google Ads campaigns via the Google Ads Campaign Management makeApiCall module. The flow is:

Webhook receives data including amount_micros (e.g. 1000000)
makeApiCall sends a POST to /v20/customers/{id}/googleAds:mutate

My JSON body looks like this:
{“mutateOperations”:[{“campaignBudgetOperation”:{“create”:{“resourceName”:“customers/{{1.customer_id}}/campaignBudgets/-1”,“name”:“{{1.campaign_name}} Budget”,“amountMicros”:{{1.amount_micros}},“deliveryMethod”:“STANDARD”}}},{“campaignOperation”:{“create”:{“name”:“{{1.campaign_name}}”,“advertisingChannelType”:“{{1.advertising_channel_type}}”,“status”:“PAUSED”,“manualCpc”:{“enhancedCpcEnabled”:false},“campaignBudget”:“customers/{{1.customer_id}}/campaignBudgets/-1”}}}]}

:thinking: What is the problem & what have you tried?

The Google Ads API requires amountMicros as an integer (TYPE_INT64), but {{1.amount_micros}} comes from the webhook as a text string. When I put it without quotes it renders as empty or causes invalid JSON. When I put it with quotes “{{1.amount_micros}}” the API rejects it as a string.

I’ve tried {{floor(1.amount_micros)}} and {{parseNumber(1.amount_micros)}} but still get invalid JSON.

:clipboard: Error messages or input/output bundles

INVALID_ARGUMENT (400) Invalid JSON payload received. Unexpected token.
“amountMicros”:,“deliveryMethod”:“STANDARD”

INVALID_ARGUMENT (400) Invalid value at ‘mutate_operations[0].campaign_budget_operation.create.amount_micros’ (TYPE_INT64), “”

INVALID_ARGUMENT (400) Invalid JSON payload received. Expected : between key:value pair.
00000,deliveryMethod":“STANDARD”
^

Hi @marc_viale. Welcome to the community.

In your JSON body,

Does not have a value and has no quotes around it.

@damato