Re: Making a REST API Call

Anonymous
Not applicable

Making a REST API Call

Hey there,
I'm trying to pre-fill a form on a non-marketo page but my javascript skills are not strong.

I found these instructions: http://developers.marketo.com/blog/external-page-prefill/

But they leave alot of steps out of the process.

I've been able to form the URL which requests an access token, but I don't know how to code the request.

None of the sample code in the dev pages is working for this purpose.

Once I obtain the access token I'll be inserting it into another URL which also contains the visitors cookie ID.

I'll be making another API call using this new URL to grab the data we need to prefill the form.

I've been able to insert the cookie ID into the URL and I shouldn't have any issue inserting the access token once it's been obtained, but again after I've formed the URL, I'm not sure how to code the call so I can get the fields I can use to prefill the form.

Can someone tell me how I make the API call in javascript?
 
Tags (1)
6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Making a REST API Call

Are you making the REST API call from server-side JavaScript, like node.js? You can't use the API directly from the browser, which is why the blog entry you point to is using a server-side PHP bridge between client and Marketo.
Anonymous
Not applicable

Re: Making a REST API Call

@Sanford W
Thanks for your reply.

I didn't realize you couldn't make the call directly from your browser. All the instructions from the Marketo dev site just tell you how to make these URLS. When you plug them into the address bar they send back the requested data so I thought it would be okay to call them that way.

Could you provide some insight into what the process would be to make the call server side?

SanfordWhiteman
Level 10 - Community Moderator

Re: Making a REST API Call

If you made the call directly from your browser you'd be exposing the private data of your organization to the public.

To make the call server-side... well, the blog post is using the Get Multiple Leads endpoint as documented here. There are Ruby and Java examples on that page that are relatively straightforward. What server-side language are you using?  
SanfordWhiteman
Level 10 - Community Moderator

Re: Making a REST API Call

Ashley, I am winding down for the day and would be happy to talk to you about this project if you're still around.   It sounds like you need some guidance about how to accomplish your requirements. Contact me at the number here if you want.
SanfordWhiteman
Level 10 - Community Moderator

Re: Making a REST API Call

Ashley/Josh, I got your chat msg but you seem to be having email problems (mail to ***@marketing-automation.com bounced).  Why don't you leave me your phone # on my chat page (or call me at the 800 number that's on there).
Anonymous
Not applicable

Re: Making a REST API Call

Hey Stanford, thank you for your replies and offer to assist.
I tried to impliment the sample code but it was throwing back errors in my console.
I've contacted you via the link you shared, please do get back to me ASAP!