How do I pass query parameters (Credentials) in Body of a tRest component

Highlighted
Five Stars

How do I pass query parameters (Credentials) in Body of a tRest component

I'm connecting to a rest API. The API provider previously accepted Login Requests to return an API key by passing the credentials as a query string in the URL.

 

e.g. POST http://pi.XXXXX.com/api/login/version/4%20HTTP/1.1?format=JSON&email=XXXXX&user_key=XXXXX&password=X...

 

This was working fine for me by using 

 

query_string.png

However, the API provider has now deprecated this method and requires the credentials to be passed in the body, e.g. this is the API Spec.

Sample POST Request

POST https://pi.pardot.com/api/login/version/3 HTTP/1.1

email=<email>&password=<password>&user_key=<user_key>

Request Parameters

Parameter Required Description

emailXThe email address of your user account
passwordXThe password of your user account
user_keyXThe 32-character hexadecimal user key for your user account

If authentication was successful, a 32-character hexadecimal API key will be returned in the following format:

<rsp stat="ok" version="1.0">
    <api_key>5a1698a233e73d7c8ccd60d775fbc68a</api_key>
</rsp>

Otherwise, the response will contain the following:

<rsp stat="fail" version="1.0">
    <err code="15">Login failed</err>
</rsp>

 I'm unable to get this to work. My revised job is as below. I'm using a tFixedFlow input to pass the credentials via a tMap into the string field of the tRest (I will used context variables to hold the relevant credentials in due course). However, I can seem to get this to work, what am I doing wrong? I know my credentials are good as I can get them to work via SOAP UI. I'm assuming I have something wrong with the syntax of the string I'm passing through. Of course because it's a logon and for security reasons the response from the API doesn't provide much clue as to what the problem is.new_job.pngtmap.pngtrest.pngoutput.png

Tags (2)
Highlighted
Five Stars

Re: How do I pass query parameters (Credentials) in Body of a tRest component

NB. The full API spec is here: http://developer.pardot.com/
Highlighted
Four Stars
Four Stars

Re: How do I pass query parameters (Credentials) in Body of a tRest component

I ended up using the tFileFetch to make the connection.  The response was saved to a cache which I parsed to get the api key.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog