Send image with API with Image Content rather that upload

Hi, I’m trying to “upload” an image by sending the image contents. Can that be done with the API?

I’m sending from SharePoint Power Automate using HTTP action:
URI: https://connect.squareup.com/v2/catalog/images
Method: PUT
Content-Type: application/json
Authorization: [my key]
Body: {“$content-type”:“image/jpeg”,“$content”:"/9j/4TodRXhpZgAASUkqAAgAAAAMAA4BAgBeAAAAngAAAA8BAgAIAAAA/AAAABABAgARAAAABAEAABoBBQABAAAAFgEAABsBBQABAAAAHgEAACgBAwABAAAAAgAAADEBAgAxAAAAJgEAADIBAgAUAAAAWAEAADsBAgAKAAAAbAEAAJiCAgANAAAAdgEAAGmHBAABAAAAhAEAACWIBAABAAAAWgMAACgEAABBIG1hbiBvcGVucyBoaXMgYXJtcywgdGFraW5nIGluIHRoZSBzY2VuZSBhdG9wIGEgc25vd3kgbW91bnRhaW4uIEFuIGluc3BpcmF0aW9uYWwgcGhvdG9ncmFwaC4Ac2Ftc3VuZwBTQU1TVU5HLVNNLUc5MzBBAABIAAAAAQAAAEgAAAABAAAAQWRvYmUgUGhvdG9zaG9wIExpZ2h0cm9vbSBDbGFzc2ljIDEzLjIgKFdpbmRvd3MpAAAyMDI0OjA1OjAyIDE3OjI1OjUyAEpheSBMaWdkYQDCqSBKYXkgTGlnZGEAABoAmoIFAAEAAADCAgAAnYIFAAEAAADKAgAAIogDAAEAAAACAAAAJ4gDAAEAAAAyAAAAAJAHAAQAAAAwMjMxA5ACABQAAADSAgAABJACABQAAADmAgAAEJACAAcAAAD6AgAAAZIKAAEAAAACAwAAApIFAAEAAAAKAwAAA5IKAAEAAAASAwAABJIKAAEAAAAaAwAABZIFAAEAAAAiAwAAB5IDAAEAAAAFAAAACJIDAAEAAAAAAAAACZIDAAEAAAAAAAAACpIFAAEAAAAqAwAAhpIHAAkAAAAyAwAAAaADAAEAAAABAAAAF6IDAAEAAAACAAAAAaMHAAEAAAABAAAAAqQDAAEAAAAAAAAAA6QD [etc.]

The error I get is:

“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “NOT_FOUND”,
“detail”: “Resource not found.”
}
]
}

I’m not sure if this is not possible of what I may be doing incorrectly.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Manage Images in a Square Catalog
Using the REST API
Using the REST API

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

You can use the HTTP PUT method with the appropriate endpoint (e.g.,https://connect.squareup.com/v2/catalog/images). and set the Content-Type header to image/jpeg. In the request body, include the raw image content (base64-encoded).

The Square Catalog API does not support uploading images by sending the image contents directly. Instead, you need to use the CreateCatalogImage endpoint to upload an image file from a server. The image file should be stored on a server and the server path to the image file should be specified in the CreateCatalogImage request. The API does not support directly embedding image data in the request.

In your case, you’re getting a “Resource not found” error because the API is expecting a server path to an image file in the request, but it’s not finding one.

To resolve this, you would need to first save the image file to a server, and then provide the server path to that image file in your CreateCatalogImage API request.

This answer was reviewed by @Bryan-Square.

Unfortunately, that did not work. Thanks though.

I solved this issue by creating an API on my web server to receive the data from Microsoft Power Automate HTTP action. The Power Automate flow already FTPs the image to the webserver, so it is there. The API I set up on the server takes that data and the image and sends them to the Square API. This works.