Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a campiagn's content #808

Closed
assafzaitlin opened this issue May 26, 2019 · 4 comments · Fixed by #821
Closed

Updating a campiagn's content #808

assafzaitlin opened this issue May 26, 2019 · 4 comments · Fixed by #821
Labels
type: support ticket that should be redirected to support

Comments

@assafzaitlin
Copy link

assafzaitlin commented May 26, 2019

Issue Summary

Hi,
I'm trying to write a script that updates my marketing campaign's content. Even though I used an api key with full access, I keep getting "403 - Forbidden" response. I tried creating a new key and it still returned the same error code. Also, I know I'm using a valid key because my get and post requests are working, and only my patch request returns this error. I looked at its permissions and it has all marketing_campaigns permissions.

Edit:
I did some more tests and saw that it works if the campaign type is "code editor" and only when it's "design editor" the patch request returns 403 status code. My meaning by campaign type is:

campaign_types

Here is a sample of my code:

sg = sendgrid.SendGridAPIClient(api_key=API_KEY)
set_campaign_id(sg, CAMPAIGN_ID)

def set_campaign_id(sg, campaign_id):
camp = sg.client.campaigns._(campaign_id)
res = camp.get()
data = json.loads(res.body)
body = {}
body['html_content'] = data['html_content'].replace(str1, str2)
body['plain_content'] = data['plain_content'].replace(str1, str2)
body['subject'] = data['subject']
body['title'] = data['title']
body['categories'] = data['categories']
res = camp.patch(request_body=body)

Technical details:

  • sendgrid-python Version: 6.0.5
  • Python Version: 3.6
@thinkingserious thinkingserious added the type: support ticket that should be redirected to support label May 28, 2019
@thinkingserious
Copy link
Contributor

Hello @assafzaitlin,

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.

Thank you!

SendGrid DX Team

@int-ua
Copy link
Contributor

int-ua commented Jul 8, 2019

I'm experiencing the same issue. Just created my account and trying to write some test Python code for creating campaigns. I've tried a couple of snippets from USAGE.md and all of them return 403 status while examples from use_cases work.

@int-ua
Copy link
Contributor

int-ua commented Jul 8, 2019

The campaign example contains integer List ID while I see UUID in web UI. It's unclear if the latter one is correct or how can I get all the ids in the example from Web UI or if it's at all possible.

@int-ua
Copy link
Contributor

int-ua commented Jul 8, 2019

You need to edit API key access at https://app.sendgrid.com/settings/api_keys

You definitely should add it to these examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: support ticket that should be redirected to support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants