I'm trying to tap the API - no dice

Anonymous
Not applicable

I'm trying to tap the API - no dice

I'm trying to call the Marketo API and I'm getting this error: net::ERR_NAME_NOT_RESOLVED

this is the function I'm using

       var marketoAPIcallURL = 'https://182-EMG-811.mktorest.com/rest/v1/';

        var apiToCall = 'lead/182.json';

        var accessToken = '?access_token=8a385a92-4a87-4e89-9eda-xxxxxxxxxxxx:ab';

        //

        console.log(marketoAPIcallURL);

        marketoAPIcallURL += apiToCall;

        console.log(marketoAPIcallURL);

        marketoAPIcallURL += accessToken;

        console.log(marketoAPIcallURL);

        //

      function callMarketoV3() {

            console.log('API CALL HAS BEGUN');

            console.log(marketoAPIcallURL);

            $.ajax({

                url: marketoAPIcallURL,

                type: "POST",

                contentType: "application/json; charset=utf-8",

                dataType: "json",

                success: function (data) {

                    console.log(data);

                }

            });

        }

Does anyone have an idea what the problem is?

Tags (1)
5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: I'm trying to tap the API - no dice

  1. That hostname does not exist.
  2. I hope you are not attempting to access the API via a browser.  You must not -- luckily, cannot -- do this.
Anonymous
Not applicable

Re: I'm trying to tap the API - no dice

that host name does not exist - i changed the first couple of numbers to 182.

why doesn't this work - could this work with node.js? If not - what method would I use to make this happen?

SanfordWhiteman
Level 10 - Community Moderator

Re: I'm trying to tap the API - no dice

that host name does not exist - i changed the first couple of numbers to 182.

You changed the hostname and wondered why it was giving ERR_NAME_NOT_RESOLVED?

why doesn't this work - could this work with node.js? If not - what method would I use to make this happen?

I have no idea what you're trying to accomplish. Please explain the project goals.

In any case, the REST API should be used for bulk operations, or singleton operations whose volume is strictly controlled by the back end that is using them. It must not be used for uncontrolled singleton operations, such as making API calls in response to individual user web actions.  Also, for technical reasons (same origin policy) you can't use the REST API via direct HTTP requests from a browser.

Anonymous
Not applicable

Re: I'm trying to tap the API - no dice

we want to have a landing page that can display data from the API. We want to personalize the landing page content to that it reflects who the user is. If there is no content related the user - we'll just render generic content. We could just use cookies - but it'll be a hosted outside of Marketo. Boss man already told me it wouldn't work - but he's not a day to day programmer - so I thought it would work. I use node as a backend - my company uses .net soooo - I guess I have my answer.

SanfordWhiteman
Level 10 - Community Moderator

Re: I'm trying to tap the API - no dice

Yep, the answer is this isn't a safe/practical/secure application for the Marketo API.

I encourage the use of Marketo-hosted Landing Pages.  They don't have to be built within Marketo, just imported. But being on the Marketo platform gives them a lot of leverage with the Marketo database.