Search code examples
twiliosendgridsendgrid-api-v3sendgrid-api-v2

Is there any filter option for X-MessageID from SendGrid response?


I have SendGrid response and here I get individual X-MessageID which is unique for all sent email, this X-MessageID is actually a starting position of Sendgrid MessageID. So here I was doing something like this "Sendgrid_MessageID Start with X-MessageID", For.Ex 'KdLh1ZETSQCWx0iqU44BTg.filterdrecv-75d94df84d-4c444-1-627963D1-45.3' start with 'KdLh1ZETSQCWx0iqU44BTg'. I have done this using SendGrid "like" operator like this =>

msg_id like 'KdLh1ZETSQCWx0iqU44BTg%'

and also try another option like

query=msg_id like 'KdLh1ZETSQCWx0iqU44BTg%'

But I get error 'invalid value' for both option, I don't undertstand how to use it. Anyone knows about how to use this "like" operator?


Solution

  • You are using the like operator correctly. When I make the following HTTP GET request using cURL, I get the message back that start with the given ID:

    curl -X GET https://api.sendgrid.com/v3/messages \
    --header "Authorization: Bearer [SENDGRID_API_KEY]" \
    --data-urlencode "query=msg_id LIKE 'W86EgYT6SQKk0lRflfLRsA%'" \
    --data-urlencode "limit=10" --GET
    

    How are you making this HTTP request?