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

Sample Code for requests to Smartlists endpoint #23

Open
evanashbrook opened this issue Sep 29, 2022 · 0 comments
Open

Sample Code for requests to Smartlists endpoint #23

evanashbrook opened this issue Sep 29, 2022 · 0 comments

Comments

@evanashbrook
Copy link

I am attempting to send a request to '/rest/asset/v1/smartLists.json' to get all SmartLists. I am authenticating with Marketo fine and recieving an access token that I include in the headers of each of my subsequent requests . Additionally, the documentation states that if our instance did not have this capability, the response code would be >1000 (It's some number I can't remember off the top of my head). However, I did not get this response code, but rather 403, which is a forbidden request. I am hoping to figure out why I am not getting a valid response, but there is no documentation for troubleshooting this endpoint.

Code:
`

def get_smartlist_ids(config, access_token):

    identity_url = config['identity_url']

    headers = {
        'Authentication': 'Bearer {}'.format(access_token),
    }

    url = '{}/rest/asset/v1/smartLists.json'.format(identity_url)

    response = requests.get(url, headers=headers)

    return response


 mkto_config = {
    'client_id': [redacted],
    'client_secret': [redacted],
    'identity_url': [redacted]
  }
  
  access_token_response = get_mkto_access_token(mkto_config)
  access_token = access_token_response.json()['access_token']
  
  print(access_token_response.status_code)
  print(access_token_response.json())
  
  smartlist_ids = get_smartlist_ids(mkto_config, access_token)
  
  print(smartlist_ids.status_code)
  print(smartlist_ids.headers)
  print(smartlist_ids.request.headers)
  print(smartlist_ids.text)
  print(smartlist_ids.url)

`

And the Output:

`

  200
  {'access_token': '[redacted]', 'token_type': 'bearer', 'expires_in': 337, 'scope': '[email protected]'}
  403
  {'Server': 'nginx', 'Date': 'Thu, 29 Sep 2022 17:54:55 GMT', 'Content-Type': 'text/html', 'Content-Length': '162', 'Connection': 'keep-alive'}
  {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authentication': 'Bearer [redacted]'}
  <html>
  <head><title>403 Forbidden</title></head>
  <body bgcolor="white">
  <center><h1>403 Forbidden</h1></center>
  <hr><center>nginx</center>
  </body>
  </html>
  
  [redacted]/rest/asset/v1/smartLists.json

`

Let me know if I can clarify or provide more information in order to help. Thanks in advance for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant