12 Replies Latest reply on Nov 24, 2018 2:55 PM by rareddy

    TEIID15005 Error Calling HTTP Service - 401 Unauthorized

    pmthirumaran

      Hi All,

       

      I am new the JDV and consuming the  Restful web service as my data source. we are passing the 'authorization' as a key and value as 'bearer token' through the header. After import, Test the connection and the Ping fails but show content shows the response as XML. After creating the view if I run it... it throughs "TEIID15005 Error Calling HTTP Service - 401 Unauthorized". Could you please help me to resolve this issue? Thanks in advance.

       

      My Teiid Designer Runtime version is 11.0.1

        • 1. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
          rareddy

          I suspect the Header you have set up during the initial process is not used in the runtime. Take look at the procedure that is calling the InvokeHTTP call in the procedures that are created, then you can manually add the Header again to the procedure. See [1] invokeHTTP procedure.

           

          [1] Web Services Translator · GitBook

          1 of 1 people found this helpful
          • 2. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
            cagreek

            Hi Ramesh

             

            We have been able to configure a REST data source, with a header bearer token in our QA Environment.    We are also able to run and test the view with a parameter to produce data from the JBOSS IDE.   The problem we are having is running the JDV service from the browser.   we get the following error.   Any incite on what we need to do?

             

             

            Response when running the URL from Chrome:

             

            <error xmlns="http://docs.oasis-open.org/odata/ns/metadata">

             

            <code>TEIID30504</code>

             

             

            <message>

             

            TEIID30504 SourceModel: TEIID15005 Error Calling HTTP Service - 401 Unauthorized

            </message>

            </error>

             

             

            • 3. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
              cagreek

              Adding the Log from the console as well:

               

               

              14:13:30,894 WARN  [org.teiid.CONNECTOR] (Worker2_QueryProcessorQueue23) Connector worker process failed for atomic-request=pr6KNOjPJLSm.0.3.11: org.teiid.translator.TranslatorException: TEIID15005 Error Calling HTTP Service - 401 Unauthorized

              at org.teiid.translator.ws.BinaryWSProcedureExecution.execute(BinaryWSProcedureExecution.java:167) [translator-ws-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:363) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_152]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_152]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_152]

              at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_152]

              at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:211) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at com.sun.proxy.$Proxy115.execute(Unknown Source)

              at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:306) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:112) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_152]

              at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:65) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:280) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:210) [teiid-engine-8.12.11.6_3-redhat-1.jar:8.12.11.6_3-redhat-1]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_152]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_152]

              at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_152]

               

               

              14:13:30,897 WARN  [org.teiid.PROCESSOR] (http-127.0.0.1:8080-2) TEIID30020 Processing exception for request pr6KNOjPJLSm.0 'TEIID30504 SourceModel: TEIID15005 Error Calling HTTP Service - 401 Unauthorized'. Originally TeiidProcessingException BinaryWSProcedureExecution.java:167. Enable more detailed logging to see the entire stacktrace.

              14:13:30,897 WARN  [org.teiid.PROCESSOR] (http-127.0.0.1:8080-2) TEIID16053 Unable to process odata request due to: TEIID30504 SourceModel: TEIID15005 Error Calling HTTP Service - 401 Unauthorized Increase the log level to see the entire stack trace.

              • 4. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                rareddy

                Is it the same environment?

                • 5. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                  cagreek

                  Hi Ramesh,  That is correct.  The same environment.   Thirumaran PM and I are working together on this issue.

                  • 6. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                    pmthirumaran

                    Hi All

                     

                    I am able to see the metadata for the following URL but when I passing the params http://localhost:8080/odata4/jsonobj/jsonobj/getcust(externalId= '12345') and getting the following error

                     

                    error xmlns="http://docs.oasis-open.org/odata/ns/metadata">

                     

                    <code>null</code>

                     

                    <message>The URI is malformed.</message>

                    </error>

                     

                    How to prepare the URL for the same?

                     

                    http://localhost:8080/odata4/jsonobj/jsonobj/$metadata

                     

                    The meta is

                     

                     

                    <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">

                    <edmx:Reference Uri="http://localhost:8080/odata4/static/org.apache.olingo.v1.xml">

                    <edmx:Include Namespace="org.apache.olingo.v1" Alias="olingo-extensions"/>

                    </edmx:Reference>

                    <edmx:DataServices>

                    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="jsonobj.1.jsonobj" Alias="jsonobj">

                    <ComplexType Name="getcust_RSParam">

                    <Property Name="userTypeCode" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="dateDisplayPreference" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="firstName" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="lastName" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="internal" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="objArr" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="lastLoginDate" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="hyphenated" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="userName" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="userId" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="email" Type="Edm.String" MaxLength="4000"/>

                    <Property Name="statusCode" Type="Edm.String" MaxLength="4000"/>

                    </ComplexType>

                    <Action Name="getcust" IsBound="false">

                    <Parameter Name="externalId" Type="Edm.String" Nullable="false" MaxLength="4000"/>

                    <ReturnType Type="Collection(jsonobj.getcust_RSParam)"/>

                    </Action>

                    <EntityContainer Name="jsonobj">

                    <ActionImport Name="getcust" Action="jsonobj.getcust"/>

                    </EntityContainer>

                    </Schema>

                    </edmx:DataServices>

                    </edmx:Edmx>

                    • 7. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                      rareddy

                      That makes no sense then, the REST call you are making is underneath the VDB, so it should be same either call through JDBC or through the browser. I suspect you have different versions of the VDB through Designer and one you deployed in the server. When in doubt, export in the Dynamic VDB format (XML/DDL) format and check the models, then deploy that to a server and test.

                       

                      Ramesh..

                      1 of 1 people found this helpful
                      • 8. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                        rareddy

                        I am not sure I understand what you are asking here @ThirumaranPM

                        1 of 1 people found this helpful
                        • 9. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                          cagreek

                          What we ended up doing is exporting the source model and making sure the result column was in the very first position of all the columns listed.

                           

                          CREATE FOREIGN PROCEDURE invokeHttp (    OUT result blob NOT NULL RESULT,  IN action string(4000),  IN request object,  IN endpoint string(4000),  IN stream boolean NOT NULL,  OUT contentType string(4000),  IN headers clob );

                           

                          Next, in the view model where JBOSS Teiid designer generates the translator you are referring to, from:     invokeHttp(action => 'GET', endpoint => VARIABLES.qp, stream => 'TRUE', headers => '{"Authorization":"bearer TOKEN"}')) AS f

                           

                          To the correct format:       invokeHttp(action => 'GET', endpoint => VARIABLES.qp, stream => 'TRUE', headers => JSONOBJECT('bearer TOKEN' AS "Authorization"))) AS f

                           

                           

                          Doing these two step allowed us to use a rest api that has a bearer token without any 401 Authorization errors.

                           

                          --------------------------------------------------------------------------------

                           

                          Ramesh, we have another question regarding bearer token.   As you can see for our testing we are hard coding in the view for testing but we need to be able to change the token depending on which environment we deploy the JDV service to.

                           

                          Can you please provide some guidance on how we can configure the view portion of  headers => JSONOBJECT('bearer TOKEN' AS "Authorization" so that the token information is pulling from an various environments.   DEV/QA/UAT/Production ?

                           

                           

                          Thanks

                          Andy

                          • 10. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                            rareddy

                            You can consider using a system property or environment variable for token. Check getenv() or system() functions

                             

                            Ramesh 

                            1 of 1 people found this helpful
                            • 11. Re: TEIID15005 Error Calling HTTP Service - 401 Unauthorized
                              cagreek

                              Hi Remesh,

                               

                              thank you for your help so far.   We need a little more guidance on how use the envirnment variable getenv() or system property system() functions

                               

                              How would we move the hard coded bearer token value we have in the view script below?   Would it be moved to the standalone.xml ?.    Can you please provide steps involved or an example on how that can be done?

                               

                              BEGIN

                              DECLARE STRING VARIABLES.qp = QUERYSTRING('https://qa-paymentsinsider.na.global.prv/api/v1/user/query', paymentsinsider.getcustomerinfo.externalMid AS externalMid);

                              DECLARE STRING VARIABLES.btoken = 'bearer eyJ0eTOKENVALUEudHMi';

                              SELECT A.userTypeCode AS userTypeCode, A.dateDisplayPreference AS dateDisplayPreference,

                              A.firstName AS firstName, A.lastName AS lastName, A.internal AS internal, A.objArr AS objArr,

                              A.lastLoginDate AS lastLoginDate, A.hyphenated AS hyphenated, A.userName AS userName, A.userId AS userId, A.email AS email, A.statusCode AS statusCode

                              FROM (EXEC paymentsinsidersource.invokeHttp(action => 'GET', endpoint => VARIABLES.qp, stream => 'TRUE', headers => JSONOBJECT(VARIABLES.btoken AS "Authorization"))) AS f,

                              XMLTABLE('/response/response' PASSING JSONTOXML('response', f.result) COLUMNS userTypeCode string PATH 'userTypeCode/text()', dateDisplayPreference string

                              PATH 'dateDisplayPreference/text()', firstName string PATH 'firstName/text()', lastName string PATH 'lastName/text()', internal string PATH 'internal/text()', objArr string

                              PATH 'objArr/text()', lastLoginDate string PATH 'lastLoginDate/text()', hyphenated string PATH 'hyphenated/text()', userName string PATH 'userName/text()', userId string

                              PATH 'userId/text()', email string PATH 'email/text()', statusCode string PATH 'statusCode/text()') AS A;

                              END

                               

                              Thank you

                              1 of 1 people found this helpful