Developer forum

Forum » Development » Mailchimp integration, API requests.

Mailchimp integration, API requests.

Villlads Nielsen
Reply

Hey, 

I'm trying to implement a basic MailChimp integration using their API. Unfourtunately the MailChimp API doesn't allow CORS requests, which blocks making this using clientside scripting. To get around this, I need to do a basic api-requests from the DW server.

I tried implementing the request logic, to fire when a GET request hit a template file, that didn't work. But I would like to do something like this. How should I do this in DW?

 

Replies

 
Nicolai Pedersen
Nicolai Pedersen
Reply

Hi Villads

It might be helpful if you describe what you have done and what the error is.

Dynamicweb has no special things you need to do in order to make a request - just regular .net code. I.e. something like this: https://stackoverflow.com/questions/27108264/c-sharp-how-to-properly-make-a-http-web-get-request

BR Nicolai

 
Villlads Nielsen
Reply

Hey Nicolai, 

I'm trying to return some JSON, from an API request to the MailChimp API.

I tried:

  • Returning JSON when a GET request is sent to a page template, i can implement the logic, but the view wont return any JSON. When i fire an Async request OnGet or on Rendering the template, the response will arrive after the view is already rendered.
  • I tried adding a custom Class, which could handle API requests, and then send an API request using jQuery on the clientside. But this didn't do anything. Where would you place a Class, cotaining some basic MVC logic that returns JSON when a GET request is sent to a certain endpoint?

Do you have another idea of what i can try?

 

 
Nicolai Pedersen
Nicolai Pedersen
Reply

You can post your code and tell us the context - then we might be able to help. It sounds like you are mixing MS MVC (maybe even .net core code??) with Razor templates in Dynamicweb - they are not the same.

You can create a normal MVC page in your project or do it in the Dynamicweb template, whatever you need.

But if the task is to do a get request to a webapi and display the result in json on a Dynamicweb page, the task should be straight forward.

 

You must be logged in to post in the forum