0

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?

Swimburger
  • 6,681
  • 6
  • 36
  • 63
D M
  • 39
  • 6

1 Answers1

2

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?

Swimburger
  • 6,681
  • 6
  • 36
  • 63
  • 1
    `queryParams = new { query = "msg_id like 'KdLh1ZETSQCWx0iqU44BTg%'", limit = 10 }; var client = new RestClient("https://api.sendgrid.com/v3/messages"); var request = new RestRequest(Method.GET);` – D M May 24 '22 at 05:13
  • 1
    My mistake, I have taken a wrong msg_id. Your solution works for me. Thank you for your time & solution , it helps me perfectly. – D M May 24 '22 at 05:20