Problem uploading b64 image via API - Vertex AI API

Hey there,

I’m trying to do a POST API call to Vertex AI endpoint from Google but I seem to be doing something wrong.

Here’s the request that I’m sending:

The b64 value I’m adding to initialise the API is what I got from an ImagetoB64 converter online.

And this is the error I’m getting:

I think I’m doing something wrong in the JSON Body of the request but I can’t figure out what exactly.

This is what Google documents say on this matter:

Any thoughts on what might I be doing wrong?

How do you encode to base64? I don’t remember that base64 message could contain an underscore: “_”
Example: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

How do you encode to base64? I don’t remember that base64 message could contain an underscore: “_”
Example: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

I use this website:

I feel that, even if you may be saying something valid, my problem is not with that part of the API call, but rather the JSON structure as a whole.

I´ve also tried selecting the option: “Perform URL-safe encoding (uses Base64URL format)”, which does provide an encoded string without underscores and I get the exact same problem …

I will add to the encoded json-safe, that instance is an array. You only set an object. Add square [ ] brackets

I will add to the encoded json-safe, that instance is an array. You only set an object. Add square brackets

Tried like this already, but same result …

Not sure which endpoint you need to reach and the configuration you have, there’s a lot of possible payload.

Have you tried to debug through Postman?

1 Like

I´ve solved this now, it was a matter of changing the name of the array param ¨b64¨to ¨content¨. Not quite what Google docs say but I saw it in a Python code sample and worked!

1 Like