Forum Stats

  • 3,757,785 Users
  • 2,251,265 Discussions


Passing token for REST API Call from ODI

User545196 Member Posts: 25 Blue Ribbon
edited Feb 15, 2020 9:20PM in Data Integrator

We have an Immediate requirement in Production for Invoking REST API which is basically asking for Token Based Authentication Please confirm if this kind of Authentication Mechanism is Available in ODI Since we only see Username and password fields in the currently Connector Used ODI Rest Connector Please provide us the necessary documentation and steps for the same curl \ 'https://xxxxxxxxxxxxxxxx/xxxxx' \ -H 'Authorization:Bearer ******************************************************' \ -H 'Accept:application/json'



  • Christyxo
    Christyxo Member Posts: 146 Silver Badge
    edited Feb 13, 2020 6:32PM

    Did you ever resolve this?

    I have a similar situation now. Using POSTMAN with the same URL, parameters and authorisation I get a valid response but when I do this via the RESTful service in ODI I get the 401 Error response.

    I have defined the topology operation as GET, added the URL, Query parameters, and placed a Header Paramater as Authorisation with the value "Bearer xxxxx".

  • Christyxo
    Christyxo Member Posts: 146 Silver Badge
    edited Feb 15, 2020 9:20PM

    I resolved my issue!

    The problem was that I had configured my dataserver with the username and password. After I removed this I didn't have the 401 error that I was getting previously.

    So now, my dataserver has the endpoint URL, no username and no password.

    My POST operation to obtain the token, includes the admin username and password in the URL

    My GET operation for data, includes the search criteria in the query parameter, and "authorization: Bearer <Token>" in the header parameter.

    It worked on the first attempt following this!

  • User_TCHO1
    User_TCHO1 Member Posts: 1 Blue Ribbon


    I have similar approach to get data from rest service. But i could not get any result. Could you please give us some examples how to do it in ODI.


  • user12003749
    user12003749 Member Posts: 10 Blue Ribbon

    It will be helpful if you are able to give the example. I could n't make it to work.

  • Christyxo
    Christyxo Member Posts: 146 Silver Badge
    edited Apr 20, 2021 4:18PM

    The REST APIs from ODI can get complex, especially given the variation of authentication methods. I've found bearer tokens to be the fastest to implement. If you require using a JSON web token, that's where it will get extremely difficult. I'm assuming that all you need here is the bearer token.

    This example is based on sending an API call to a fictitious REST service ""

    Create a dataserver in your topology for ABC, and add "" as the endpoint. Note that I haven't included "/API/customer" because that's the resource and the operation. You do not need to record anything else here.

    Create a physical schema in this dataserver and record the resource as API. This completes the "" part of the URL to the REST service.

    In the operations panel of the physical schema, Press the plus symbol to create a new operation.

    The name is for your own reference and has no bearing on the REST request. Name it something appropriate for your operation.

    • The position is sequential. You won't need to change this.
    • The method in this case is GET for this operation.
    • The operation URL in this case is "customer". This completes the URL as ""
    • Click within the query parameter section to add your parameters (if required). My example is a parameter with the name "Customer_ID" and the value of 100. This gets interpreted as "customer_id=100".
    • Click within the Header Parameter section to add your headers (if required). My example is a Bearer Token. The Token has been provided by my REST service provider. I chose the type of Authorisation, and then typed the word Bearer followed by the provided token.

    If you click on Test Restful Service, you should see the appropriate REST operation, parameters and headers

    Create a new physical schema to connect your context to the resource

    Now your topology is complete. You need to invoke the RESTful service through a package.

    Note that for any release prior to ODI, there is a bug in the invoke component which will force you to choose a context. This has been resolved in and later but you may be required to install a patch as per the support page here:

    Create a package, and insert the component OdiInvokeRESTfulService, select the logical schema and the operation.

    I have found that if I use the default settings from the topology my package fails so I always bring the desired values into Request Header and Request Query as per the below.

    You will also need to specify a file path for the JSON/XML response file, and whether or not you wish to Append the results to the file or build a new file with each request.

    The command behind this component using my examples looks like:

    OdiInvokeRESTfulService " "-LSCHEMA=ABC.API.customer" "-OPERATION=customer" "-RESPONSE_FILE=C:\DEV\ABC\customer.json" "-APPEND_RESPONSE=NO" "-TRACE_FILE=C:\DEV\ABC\customer_trace.txt" "-APPEND_TRACE=YES" "-HEADER.Authorization=Bearer zxcasdqwe123" "-REQUEST_QUERY.customer_id=100"

    Executing your package now should issue an authorised request and output the results at the location specified.

    Note: My example will fail if you copy this since it's a fictitious web service.

  • user12003749
    user12003749 Member Posts: 10 Blue Ribbon

    Appreciate it much Christyxo. I will give it a try and let you good folks know how it went. Thanks.

  • Dung Dinh-Oracle
    Dung Dinh-Oracle Member Posts: 5 Employee

    In Request Header part, how we pass a variable to Authorization?

  • Christyxo
    Christyxo Member Posts: 146 Silver Badge

    A bearer token?

    Create a variable with such as

    Select "Bearer xxxxxx" from dual;

    Replace xxxxxx with your actual token.

    Then simply add a request parameter called Authorisation and add your variable into the value. You don't need to apply quotes around the variable.

    That should be enough.

    Its worth noting that you should do this in the package. The package will overwrite any defaults from the topology.

  • Dung Dinh-Oracle
    Dung Dinh-Oracle Member Posts: 5 Employee

    It is a API token because API token has expiry time so the API token variable is refreshed when the ODI starts.

    I tried to pass the token variable as below but its not working

  • Dung Dinh-Oracle
    Dung Dinh-Oracle Member Posts: 5 Employee

    Quick update

    I found out the wrong format value of the token variable. I fixed and worked.