Removing contacts from a list using v3/Fluent interface
Closed this issue · 1 comments
Issue Summary
When trying to structure the request for the (newish) Fluent interface, I continually get 400 errors with very little other information. Adding contacts to lists works well, but removing them does not (for me, anyway). Is this not the correct way to format the call for this endpoint.
Code Snippet
import sendgrid
sg = sendgrid.SendGridAPIClient()
contact_id = "<id-here>"
list_id = "<list-id-here>"
resp = sg.client.marketing.lists._(list_id).contacts.delete(request_body=dict(contact_ids=contact_id))
Exception/Log
Traceback (most recent call last):
File "/Users/davidhagan/.pyenv/versions/3.6.5/lib/python3.6/code.py", line 91, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/Users/davidhagan/Library/Caches/pypoetry/virtualenvs/aq-backend-9Ru8nYv1-py3.6/lib/python3.6/site-packages/python_http_client/client.py", line 262, in http_request
self._make_request(opener, request, timeout=timeout)
File "/Users/davidhagan/Library/Caches/pypoetry/virtualenvs/aq-backend-9Ru8nYv1-py3.6/lib/python3.6/site-packages/python_http_client/client.py", line 178, in _make_request
raise exc
python_http_client.exceptions.BadRequestsError: HTTP Error 400: Bad Request
Technical details:
- sendgrid-python version: 6.3.1
- python version: 3.6.5
According to the documentation you linked, the contact_ids
parameter is a query parameter, which means you would structure your request like this:
resp = sg.client.marketing.lists._(list_id).contacts.delete(query_params=dict(contact_ids=contact_id))
If this doesn't work and you need further help, please refer to the error handing guide to print the full error output and post the content in a follow-up comment so we can help you debug.