Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Davew1
Contributor II
Contributor II

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 

 

0683p000009M8m7.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

email X The email address of your user account
password X The password of your user account
user_key X The 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.0683p000009M8xj.png0683p000009M8kL.png0683p000009M981.png0683p000009M986.png

Labels (2)
1 Solution

Accepted Solutions
Davew1
Contributor II
Contributor II
Author

In the end the solution turned out to be so (annoyingly) simple!0683p000009MZqx.jpg

I just had to change the Content Type Dropdown from JSON to FORM

View solution in original post

4 Replies
Davew1
Contributor II
Contributor II
Author

NB. The full API spec is here: http://developer.pardot.com/
ken7
Contributor
Contributor

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.


Pardot Authenticate.PNG
Davew1
Contributor II
Contributor II
Author

In the end the solution turned out to be so (annoyingly) simple!0683p000009MZqx.jpg

I just had to change the Content Type Dropdown from JSON to FORM

Mopi
Contributor
Contributor

Hi guys,

I am facing a similar problem (at least I think so), with a banking API that I call to get some customer information. The whole API works with OAuth 2.0.

The process is as follows: first I call an authorization URL of the API (GET request with my Client_ID, Redirect URI and response_type = "code"), I then get redirected to a login page, where the user (whose info I want) has to enter his/her credentials (Branch, account id, subaccount id, pin). Once this is done, the user grants me access to its data and I get the token. My problem is that I dont know how to handle the step after the GET request. The response I get from calling the authorization URL is HTML, but I have no idea how to parse the user credentials into it. Itried another tRestClient, that takes in the response of the first tRestClient (which is a redirect to the user login site) and makes a POST call the user credentials (see screenshot). However, I am getting a 403 in the 2. tRestClient. Do you have any idea how to work with the response of the first tRestClient? Can I save it somehow? Any held would be greatly appreciated!

0695b00000DsuiJAAR.png