How to retrieve e-mail campaign information via API

Options

Hey all,

I have been trying to get information about e-mail campaigns running on my organization's Domo instance.

I have been able to find the information needed through a GET request at the following endpoint: https://campaigns-prod.domolabs.io/api/v1/email/campaigns/

However, I struggle to authenticate correctly. I tried using a bearer token, an access token generated at developer.domo and some other methods (mainly using client_id and client_secret). I also tried using the request header "X-DOMO-Developer-Token".

I have been able to access the information authenticating via a request header "X-Auth-Token", using a value I found in a request in the network tab of the inspector panel in the browser while inspecting the relevant campaign app.

How can I generate said token, or any other correct way of authentication, for this specific purpose? I'd prefer to avoid 3rd party libraries, but would be willing to use pydomo.

Thank you

Tagged:

Answers

  • ArborRose
    Options

    If you are trying to call an API, perhaps you could look at the Domo AppStore for an appropriate API connector. Search JSON. Some connectors require tokens or some type of authentication account to be configured. Possibly something like the No Code oAuth Connector.

    I use this type of connector to connect to my data source. Once I have the account configured, I simply select it from the dropdown.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • ellibot
    ellibot Contributor
    Options

    @PedroM

    Interesting, did you also try 'x-domo-developer-token' as the header? Not sure if it is case sensitive. Did you also have 'Accept' and 'Content-Type' as application/json in the request? I find that this can sometimes cause the request to fail.

  • PedroM
    Options

    @ellibot

    Thank you for your suggestions. I did try both 'x-domo-developer-token' as the header, and 'Accept' and 'Content-Type' with 'application/json' as value. Still doesn't work, unfortunately.

  • PedroM
    Options

    @ArborRose

    Thank you for your suggestions. I may be mistaken but I believe your solution is not quite what I'm looking for, since what I am trying to do is connect to Domo from an external source to extract data from Domo. Not the other way around. Let me know in case I misunderstood what you meant

  • ArborRose
    Options

    Is this what you are looking for? In Python…..


    import requests

    client_id = 'your_client_id'client_secret = 'your_client_secret'url = 'https://api.domo.com/oauth/token'data = {
    'grant_type': 'client_credentials',
    'client_id': client_id,
    'client_secret': client_secret
    }

    response = requests.post(url, data=data)
    token = response.json()['access_token']

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • ellibot
    ellibot Contributor
    Options

    @MattTheGuru this sounds related to your question. You aren't able to access Campaign resources using the normal x-domo-developer-token, correct?

  • MattTheGuru
    MattTheGuru Contributor
    Options

    Yeah, @ellibot that's correct. The dev token doesn't work in this case, BUT @NoahFinberg found a great solution.

    Check out these awesome docs:

    https://domo-support.domo.com/s/article/360043441853?language=en_US

    If these trouble you at all mention me and I'll record a video showing a demo :)

  • PedroM
    Options

    @ArborRose

    Thank you for your suggestion. Not quite, credentials generated that way don't work on this endpoint.

  • PedroM
    Options

    @ellibot

    Thank you so much for your contribution and tagging other people!

  • PedroM
    Options

    @MattTheGuru

    Thank you for that reference! I had already come across it, but it didn't really seem to apply to my situation, so I ignored it.

    I tried doing a GET request to https://campaigns-prod.domolabs.io/api/v1/email/campaigns/ with 'domoAccessToken', 'domoAccessTokenOwnerEmailAddress', and 'instance' as headers. But it still doesn't work, returning a 403 response ('Forbidden').

    I would greatly appreciate if you could do a demo as you suggested. Just bear in mind, please, that my goal is to retrieve information on the existing campaigns in the instance. Something that I can do through a GET request to the endpoint stated above and providing a 'X-Auth-Token' header with a value (which is user-specific) that I found in the network tab of the inspector panel in the browser. Let me know if any other details are necessary.

    Thank you in advance!