I am trying to use the curl interface to SendGrid to send an email with an embedded image (not an attachment) and cannot work out the correct syntax. I am also on Windows, so the issues with the json quotes and the windows command line mean I have to create a file and use the curl -d option.
Here’s my curl command:
curl –url https://api.sendgrid.com/v3/mail/send –request POST –header “Authorization: Bearer ” –header “Content-Type: application/json” -d “@E:tempcurl_RCC_20240506104528.tmp”
Here’s my temp file contents:
{“personalizations”: [{“to”: [{“email”: “[email protected]”}]}], “from”: {“email”: “[email protected]”}, “subject”: “folio number”, “content”: [{“type”: “text/html”, “value”: “Image file = E:/images/allproplogo.jpg
“}] ,”files”: [{“filename”:”allproplogo.jpg”, “type”: “image/jpeg”, “cid”:”image0001″, “content”:” base64encodedimage “}]}
In response, I get this error message
{“errors”:[{“message”:”Bad Request”,”field”:null,”help”:null}]}
I have tried various combinations of base64 encrypting the message, but I either get this message or a bad UTF8 response.
William Hawkins is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.