SOLVED

Rest API - Translated Forms - CORS issue

Go to solution
dabelard
Level 2

Rest API - Translated Forms - CORS issue

I am trying to update the translated forms we have running that use this methodology: https://nation.marketo.com/t5/product-discussions/marketo-form-localization-translations/m-p/53988#M...

 

I updated the submission endpoint, base url, etc to use the REST API information, but I am getting a CORS error.   I am also wondering if I need to reformat the information.  I was able to successfully submit in Postman, but when I added the code to this page: https://sovos.com/it/libreria-dei-contenuti/iva/post-brexit-iva-norme-e-book-proteggere-transfrontal... I end up with the CORS error in addition to some CSS issues.   

 

I am not sure how to resolve the CORS error, as I am using the URLs provided which are all new and substantially different from both the LP URL and the direct marketo ##--app.marketo.com URL as well. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue

The REST API is never to be used directly on web pages. The error is expected.

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue

The REST API is never to be used directly on web pages. The error is expected.

shenhuidarren
Level 1

Re: Rest API - Translated Forms - CORS issue

How it should be use?

Tags (1)
SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue


How it should be use?

The Marketo REST API (like most such APIs) is for server-to-server or app-to-server communication. Not browser-to-server.

 

And even if you gateway requests from the browser through a back end that in turn communicates with Marketo, you must pay very close attention to per-IP rate limits. Otherwise, you’re letting anonymous people consume your API calls just by interacting with the page.

dabelard
Level 2

Re: Rest API - Translated Forms - CORS issue

Hi Sanford, 

 

So how do I update these forms?!  This was the solution I was given by Marketo support in order to replace the translated forms.  Is there a different way to update the original code you suggested / gave for translating forms.  We have hundreds of these forms across a dozen sites that are all going to stop working shortly due the depreciation of the original methodology for posting the forms. 

 

Please note: I am not a developer.  I am a marketer with an understanding of some code.  I learned the rest API functions on my own to update this per the direction I was given by Marketo Support. 

 

IS there a solution for this? 

 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue


We have hundreds of these forms across a dozen sites that are all going to stop working shortly due the depreciation of the original methodology for posting the forms.

Well, you have to use JavaScript that’s compatible with the new functionality. Certainly the REST API will never be the solution.

dabelard
Level 2

Re: Rest API - Translated Forms - CORS issue

Can you please expand on what you mean by that?  Is there new JS that works without the /save /save2 / POST methodology?   I will keep digging, but would appreciate any additional direction you can give.

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue


Can you please expand on what you mean by that?  Is there new JS that works without the /save /save2 / POST methodology?

Yes, it needs to be modified for the new endpoints, like here: MktoForms2 :: Manual descriptor, localize <select> v2.0.0

dabelard
Level 2

Re: Rest API - Translated Forms - CORS issue

Thought this was working, but Marketo just shut it down again.  Still using depreciated endpoints save and save2.  Get functions 404. 

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest API - Translated Forms - CORS issue

Updated for compatibility with new library: MktoForms2 :: Manual descriptor, localize <select> v2.1.0