Six Stars SD
Six Stars

Need help in calling a API in Marketo

I have tried several options to call for the API (details in the API, in URL mentioned below), through Talend.

I am able to call the API from Google/ARC, but is not able to do so from Talend. Would need some guidance on that.  ( http://developers.marketo.com/rest-api/bulk-import/bulk-lead-import/ )

I have tried these options:

i) Read a csv (through tFileInputDelimited) and converted that data to json and call the API via tRestClient component. I keep getting error "Invalid Content Type"

ii) I have also tried just calling the API using tFileInputDelimited(CSV option) and tRestClient giving all the required header parameter.This also gives the same error.

The API request is /bulk/v1/leads.json.Looking at the API call, it looks like it needs json input (as the URL suggest).From documentation, I understand that the API  needs CSV file with content type as multipart-form-data (as part of Header parameter). How do I achieve this in Talend.

Please let me know if you need more details or clarification to guide me.

15 REPLIES
Fifteen Stars

Re: Need help in calling a API in Marketo

Can you post a screenshot of what you have tried? This will give us an idea of what to suggest. My initial thoughts are that you have not set the HTTP method to "POST" and Content-Type to "FORM". I *think* the Accept-Type should be "Multipart" as well. However, it is much easier to try these things out quickly than to list suspected issues.

Rilhia Solutions
Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

Thank you for the response. I have set the HTTP method as POST, Content-Type as Form and Accept Type as Any. Attaching the screenshot of the tRestClient Basic and Advanced setting.

Please let me know if there is clarification needed.

Thank you.

Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

Thank you for the response. I have set the HTTP method as POST, Content-Type as Form and Accept Type as Any. Attaching the screenshot of the tRestClient Basic and Advanced setting.

Please let me know if there is clarification needed.

Thank you.

Fifteen Stars

Re: Need help in calling a API in Marketo

First I'd recommend changing the Accept Type to Multipart and try that out....although I'm doubtful that will make the difference. Next....unfortunately I could not make out anything from the images as the resolution is too poor

Rilhia Solutions
Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

Thank you for your response.

There is no 'multipart' as the Accept type or Content Type. And since the data needs to go to Marketo in multipart, I thought that the Accept type as Any should be ok.

I am attaching the pictures with better resolution.

 

Fifteen Stars

Re: Need help in calling a API in Marketo

Sorry, I was using 6.5 when I looked at this. I take it you are not using that version. Leave that as it is. Try changing your header in the Advanced Settings to "Content-Type". I don't believe that case should matter, but I have seen it make a difference in the past. At the moment, your content-type selected by the drop down corresponds to "application/x-www-form-urlencoded".

Rilhia Solutions
Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

Yes, my version is 6.2.1.

Are you saying to change the "content-type" to "Content-Type".

I did that in the URL (in Basic setting and in Advance setting - changed the "content-type" to "Content-Type" and value is set to "multipart/form-data" ) of tRestClient and left the other settings as in the attachment and getting the error: "Invalid multipart request".

Thanks so much, hope we will be able to resolve this soon.

Fifteen Stars

Re: Need help in calling a API in Marketo

Well that seems to show a step forward from before. So now we look at the next issue. I have just looked again at your requirement and it looks like you need to send an actual file...not just some JSON. Is that correct? If so, you may wish to change your component to a tFileFetch. Tick "Add Header" and set your content-type like before. Ensure that "POST method" is ticked. Set the URI as before. Go to Advanced Settings and select Upload File. Configure the file that you want to send in the table that appears there. This may need some trial and error.

Rilhia Solutions
Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

Hello:

 I had tried this option before as per some website suggestions and was stuck with an error.So now when I tried, I got the error back. 

C:\defaultfilename.txt (Access is denied).

Where is this setup coming from and how can i can change where the file gets written as I don't have permission to write a file under c:\.

Thanks.

Fifteen Stars

Re: Need help in calling a API in Marketo

You shouldn't be writing the file to your local filesystem, simply picking it up to send. Can you show me your configuration?

Rilhia Solutions
Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

I am trying to call a API to POST a csv file to marketo.

Is tFileFetch the right component for me to upload the file to marketo for bulk update.

The description of this component says "tFileFetch allows you to retrieve file data according to the protocol which is in place.".

 

 

 

Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

Attaching the changes.

When I run this, the error message is going to the output.csv as- 

{"requestId":"c92b#1616d14727e","success":false,"errors":[{"code":"1002","message":"Missing value for required parameter 'file'"}]}

 

And the Execution output is as:

Starting job pocbulkleadstfilefetch at 16:45 06/02/2018.

[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - TalendJob: 'pocbulkleadstfilefetch' - Start.
[statistics] connecting to socket on port 3659
[statistics] connected
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - tFileFetch_1 - Connection attempt to 'mktorest.com/bulk/v1/leads.json?access_token=2282365a-1a99-46c5-927b-1e7fdc8590e0:ab&format=csv&file=BulkLeads.csv&content-type=multipart/form-data
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - tFileFetch_1 - Connection to 'mktorest.com/bulk/v1/leads.json?access_token=2282365a-1a99-46c5-927b-1e7fdc8590e0:ab&format=csv&file=BulkLeads.csv&content-type=multipart/form-data' has succeeded.
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - tFileFetch_1 - Closing the connection to the server.
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - tFileFetch_1 - Connection to the server closed.
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - tLogRow_1 - Content of row 1: ,
,
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - tLogRow_1 - Printed row count: 1.
[statistics] disconnected
[INFO ]: redshift_dev.pocbulkleadstfilefetch_0_1.pocbulkleadstfilefetch - TalendJob: 'pocbulkleadstfilefetch' - Done.
Job pocbulkleadstfilefetch ended at 16:45 06/02/2018. [exit code=0]

Fifteen Stars

Re: Need help in calling a API in Marketo

Why do you have headers in your URL? They should be configured in the headers section (Content-Type, etc). Also, the information as to what the service needs is very light. How have you got it to work with Google/ARC? What did you send? WHat did you get back? It is REALLY hard to debug web services when you can't try them yourself.

Rilhia Solutions
Six Stars SD
Six Stars

Re: Need help in calling a API in Marketo

I am attaching the ARC request/response screen shots along with Talend setup.

In Talend I have been trying all possible combinations- with header in URL or without header in URL and as part of header parameters we well.

So far no luck.

I re-tried using setting as you mentioned. In the response (part of attachment), I see that it is taking  "Content-Type: application/json;charset=UTF-8" - Not sure how.

Also output.csv file says:"Invalid multipart request".

Also if you please let me know if it is worthwhile trying with tRestClient or tFileFetch (Doc says tFileFetch- tFileFetch allows you to retrieve file data according to the protocol which is in place.). We are not retrieving file, but sending it. Am I on right track using tFileFetch?

I am really looking forward for some directions from you.I appreciate all your help.

Thanks,

Fifteen Stars

Re: Need help in calling a API in Marketo

The tFileFetch component is poorly named. I believe the "Upload File" functionality was introduced as an enhancement. The name should have changed. I noticed in your tFileFetch that you didn't have a Parameter called "file" configured. This *could* be the issue given your last error message. In fact ALL of your Query Parameters need to be specified in the Talend Parameters section. Try the configuration exactly as before when you got the last error message about a missing "file" parameter and add the parameters I mentioned above.

Rilhia Solutions