Not sure, that’s just my interpretation of that error.
Actually I’ve tried with Contact IDs and found the same error (1st image below). So I think it’s a bug in the code (2nd image)
Hah
In the code, it will search for the Contact Emails to get the Contact IDs, then concatenate the search result to the Contact IDs prop, so I think it’s okay to have the Contact IDs empty
Wait, the 2nd screenshot is the component code?
Wait, the 2nd screenshot is the component code?
Yes the 2nd screenshot is the component code
Ok gotcha, thanks. Nice debugging, Leo.
I will submit a ticket for this.
@U05AFCJEXB8 sorry for the inconvenience, it seems like to SendGrid remove Contact from List action is broken for now. As a workaround, I would suggest to use the SendGrid API directly. I will ask the Pipedream bot to generate the code for you
On Pipedream, how to use SendGrid API to remove a contact from the existing list. I have the contact email referenced from steps.retrieve_customer.$return_value.email
I understand that you want to remove a contact from a SendGrid list using the SendGrid API on Pipedream. Since the built-in action seems to have an issue, you can use the SendGrid API directly in a code step. Here’s an example of how to do that: First, make sure you have your SendGrid API key. You can find it in your SendGrid dashboard under API Keys. Next, add a code step in your Pipedream workflow and use the following code: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { sendgridApiKey: { type: "string", label: "SendGrid API Key", secret: true, }, listId: { type: "string", label: "List ID", }, email: { type: "string", label: "Email", default: steps.retrieve_customer.$return_value.email, }, }, async run({ $ }) { const headers = { Authorization: `Bearer ${this.sendgridApiKey}`, "Content-Type": "application/json", }; // Search for the contact by email const searchResponse = await axios($, { method: "POST", url: "https://api.sendgrid.com/v3/marketing/contacts/search", headers, data: { query: `email = '${this.email}'`, }, }); if (searchResponse.length === 0) { console.log("Contact not found"); return; } const contactId = searchResponse[0].id; // Remove the contact from the list await axios($, { method: "DELETE", url: `https://api.sendgrid.com/v3/marketing/lists/${this.listId}/contacts/${contactId}`, headers, }); console.log("Contact removed from the list"); }, });
Make sure to replace the sendgridApiKey
and listId
props with your actual SendGrid API key and the ID of the list you want to remove the contact from. The email
prop will be automatically set to the email from the previous step (steps.retrieve_customer.$return_value.email
).
I got ReferenceError: steps is not defined error. Looks like the part **default**: steps.retrieve_customer.$return_value.email,
is incorrect
It also didn’t use the app prop, so not a great response. Maybe the code generation feature in the builder can help!
Apologies for the confusion. It seems I made a mistake in the code. You should remove the default
value from the email
prop and reference the email in the run
method instead. Here’s the corrected code: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { sendgridApiKey: { type: "string", label: "SendGrid API Key", secret: true, }, listId: { type: "string", label: "List ID", }, email: { type: "string", label: "Email", }, }, async run({ steps, $ }) { const email = steps.retrieve_customer.$return_value.email; const headers = { Authorization: `Bearer ${this.sendgridApiKey}`, "Content-Type": "application/json", }; // Search for the contact by email const searchResponse = await axios($, { method: "POST", url: "https://api.sendgrid.com/v3/marketing/contacts/search", headers, data: { query: `email = '${email}'`, }, }); if (searchResponse.length === 0) { console.log("Contact not found"); return; } const contactId = searchResponse[0].id; // Remove the contact from the list await axios($, { method: "DELETE", url: `https://api.sendgrid.com/v3/marketing/lists/${this.listId}/contacts/${contactId}`, headers, }); console.log("Contact removed from the list"); }, });
Now, when you add this code step to your workflow, you can reference the email from the retrieve_customer
step in the “Email” prop field.
Thank you , thank you @U02A06JPKEH. Seems to be coming up with this now
Hi , as I DMed you, could you delete the image you posted? It is exposing your sensitive info. I will work with you on DMs regarding the workaround
Yeah the builder AI code gen should work much better, we need to get Pi talking directly to that
I’m seeing this error (Unexpected token '?.'
) in other components as well. It seems to appear whenever a custom expression containing an array is entered.
Interesting. We made a potentially related change to step references last week and eng is investigating. Can you point me to other specific examples, Michelle?