Adding money to pots returns an error that the value must be more than 0

I’ve been writing some Google Scripts for myself so I can look at my Monzo bank in Alfred (macOS app), it lists all of my pots but when I wanna add money to a pot I get this error:

{“code”:“bad_request.bad_param.amount”,“message”:“must be greater than 0”}

It’s weird because I have definitely added the amount value (my amount) * 100
Any idea what could be wrong? Thanks.

Are you (a) ensuring it’s a float/double before multiplying? Some languages (I’m looking at you, Python) do some funky things; (b) ensuring the result of your multiplation is then an integer before firing off the request?

That’s be where I’d start my debugging, based on description alone.

Have you tried dumping out the payload you’re sending and just looking at the data being sent?

2 Likes

Thanks for your response, but unfortunately it returns the same error when I manually set the value of the amount to 100, which should be 1 GBP , right?

By the way this is what it’s gonna be, I just wanna be able to add or withdraw money from pots when I select one of my pots in Alfred. I think it’s a really cool idea…

2 Likes

You’re passing the account Id, amount and dedupe Id as a header. Should these not be part of the body?

What does your fetch() method look like?

I have also tried to put them as a payload, but it’s also in the url as parameters.
This is what I get back from Monzo

Can you change the url you’re making the request to, to your own postbin?

https://postb.in/

You’ll then be able to see what payload monzo are receiving and we might get somewhere.

That site has had some issues, if you want I can console log my options variable before sending it, I will only censor my auth token…
I have also installed httpie like the documentation says, copy pasted their example only replaced them with my actual values, so Monzo API does work, I only have no idea how I should send my request with google script…

This one works too.

You’ll probably find it far easier to debug by posting to postbin (or similar) and seeing the exact payload you’re sending. Remove your auth token before doing so, if you plan on sharing the output.

I’ve just got it to work. My current code looks like this:

Thanks for your help. :wink:

I spotted the original post with the output - was it related to the fact the data was in the query string and not the body?

Glad you got it working :slight_smile:

Yes, and also the amount has somehow ended up with a decimal, so now I use amount.toFixed(0)

1 Like