Reputation: 5768
I'm trying to use the sendgrid curl for adding a new contact.
This is what I got
curl --request PUT \
--url https://api.sendgrid.com/v3/marketing/contacts \
--header 'authorization: Bearer myAPIKEY' \
--data '{"contacts":[{"email":"[email protected]","first_name":"Karel","last_name":"Deb"}]}’
But it returns this
{
"errors": [
{
"field": "",
"message": "invalid JSON"
}
]
}
What am I doing wrong?
Thank you!
Upvotes: 0
Views: 3951
Reputation: 812
You are not specifying that the body is of type JSON. you need to add --header 'Content-Type: application/json' \
to your request.
curl --request PUT \
--url https://api.sendgrid.com/v3/marketing/contacts \
--header 'authorization: Bearer myAPIKEY' \
--header 'Content-Type: application/json' \
--data '{"contacts":[{"email":"[email protected]","first_name":"Karel","last_name":"Deb"}]}’
Upvotes: 4