Using Bearer token for extracting data through APIs

I need to extract data through API which has a bearer token provided with it.

Do I need to configure an environment variable and internal user API permissions before to get the

curl -k <link> -H "Authorization: Bearer <token>-d search<search parameter> -d output_mode=json

working?

 

How to get the curl command run successfully?

Hi @nisheeth.jaiswal1634889927792​,

Curl will likely run just fine in a Bash script but you are better off investing some energy into setting up and using Matillion's API Profiles and API Extract Profiles for this type of task as it will quickly pay off when you start introducing other API calls.

Hi @Bryan (Customer)​

On configuring the API extract profile when using the URI link and the bearer tokens it shows error

Request header parameters:

Authorization: ********

Status code received: -1

Response headers:

[Error]: Error carrying out request.

null.

what should I do.

The documentation says:

Below is a step-by-step guide to accessing the Matillion ETL REST API response using a bearer token:

  1. Configure the environment variables for Matillion ETL.
  2. Create an internal user with API permissions in Matillion ETL.
  3. Make an API call request to the Matillion server using a bearer token.

Can u suggest what should be done here?

Also pls suggest some useful resources for bearer tokens in Matillion.

I did the Global connectors tutorial but it doesn't covers anything on configuring bearer tokens, it only uses API key value pair.

Looking forward to your response.

Hey @nisheeth.jaiswal1634889927792​,

My understanding is that you only need to create an internal user with API permissions if you wish to interact with Matillion's own API. If you are trying to access an external API (which I believe is the case here) then you should be able to proceed by working through the menus when trying to configure an API Query Profile.

When configuring an endpoint connection using the API Query Profile functionality in Matillion, you should be able to configure authentication through several options, including a bearer token:

I hope this helps

Hi @ChrisHastie-InterWorks

I have already tried it and the above error I am getting in the API extraction profiles also when using the API query profile I get an https certificate error

I followed the steps which are covered in the Global connector training course and it shows

Request header parameters:

Authorization: ********

Status code received: -1

Response headers:

[Error]: Error carrying out request.

null.

Is there any other support on this issue or documentation or a call possible?

Hey @nisheeth.jaiswal1634889927792​ ,

The main areas I would look at for this are:

My personal recommendation would be to figure out your API connection through Postman first This way you can test connectivity to your API without clouding the water with understanding it from a Matillion perspective. Once you get your API connection working through Postman in a way that makes sense for you, you can then convert it to a cURL script directly within Postman, or use your improved understanding to develop the API connection in Matillion.

Unfortunately, I personally don't think I can help you more with this without knowing more about the API that you are trying to access. Each API is configured in its own way and thus there is no "one-size-fits-all" answer describing how to connect to an API.

If you are getting the cert error you might check the URI you are using for the call. If you are calling the Matillion API there is a good chance that your server isn't using SSL. Meaning, your URI should start with HTTP:// instead of HTTPS://. the documentation on the Matillion API is your friend in the case. If you are making the call to the Matillion API that resides on the same instance the job is calling then your URI should start with http://127.0.0.1:8080/rest/v1/. If you do in fact have SSL setup on your Matillion instance then you should be using https://127.0.0.1:8080/rest/v1/. If you are testing the Matillion API via something like Postman, then you will want to replace the 127.0.0.1:8080 with just the IP of you Matillion instance (i.e. http://169.169.169.169/rest/v1/). Of course this only pertains to if you are calling the Matillion API. The documentation Chris pointed out is valuable. Another training resource you might check out is the video on API Profiles which is a new release from the documentation team: https://youtu.be/Ts6k9aHs7QA