Perlnerd
Posts: 1
Joined: Wed Apr 12, 2017 9:37 pm

How to make HTTPConnector POST request with JSON from JSONWriter

Postby Perlnerd » Wed Apr 12, 2017 10:01 pm

I'm new to CloverETL, with some previous experience in PDI. I'm trying to prototype a graph that queries a mysql database for email addresses, and make an API call to mailchimp to subscribe the address to a list.

The issue I'm having is how/where to configure HTTPConnector to send the incoming JSON string to the Mailchimp endpoint. I was able to get this working easily in PDI, but have hit a wall in CloverETL

The JSON string looks like the following:

{
"status" : "subscribed",
"email" : "this@that.com"
}

Attached is a copy of the graph, if that will help.

Thanks!
Attachments
mailchimp_anon.grf
(3.02 KiB) Downloaded 9 times

anyeone
Posts: 12
Joined: Thu Feb 09, 2017 4:30 pm

Re: How to make HTTPConnector POST request with JSON from JSONWriter

Postby anyeone » Thu Apr 13, 2017 6:35 pm

Hi there,

I've been posting to a lot of REST services from my Clover projects so hopefully I can assist.

If you have the JSON write to a port, you should be able to send it as input to a Reformat object that has the HTTPConnector_Request as its output metadata.

Then, map the JSON to the requestContent of the output. (If you have any other dynamic content for your HTTPConnector_Request you can configure it in this Reformat as well. For example, I create the URL dynamically using job parameters.)

In the HTTPConnector_Request you can set the HTTP action as PUT, POST etc. as needed and set the URL that you are posting to.
Then in the Input Mapping you can drag the requestContent from the request to the HTTPConnector's requestContent (and set any other parameters you configured in the Reformat and mapped to the HTTPConnector_Request.

I hope that helps you figure it out!

jandikovae
Posts: 20
Joined: Fri Nov 04, 2016 8:51 am

Re: How to make HTTPConnector POST request with JSON from JSONWriter

Postby jandikovae » Wed Apr 19, 2017 1:42 pm

Hi,

I have reviewed your situation too and I decided to create an example graph for you so that you can review the exact HTTPConnector setup on your original graph (I have slightly updated the graph and simplified it for testing purposes).

I would recommend you to start from a scratch with the HTTPConnector and update only following fields: URL (whatever you have used for MailChimp before), Request method (POST), Input Mapping (more details below and in the graph) and Username/Password.

I would like to bring to your attention especially Input Mapping attribute. On the Input mapping screen, map "field1" to the requestContent field.

In addition, I have also noticed that in the URL attribute you are using parameter ${MC_LIST_ID}, which is not defined in the graph that you have provided for review. I suppose that you are using "externalized parameter" and that is why it is not part of the graph. Is that right? If not, make sure the parameter is defined as well.

Please review and let us know if you have any follow-up question.

Eva
Attachments
mailchimp_updated.grf
(3.28 KiB) Downloaded 6 times
---
Eva Jandikova
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com
How to speed up communication with CloverCARE support