7 Replies Latest reply on Apr 4, 2018 9:03 PM by rptmat57

    HTTP header is not set in invokeHTTP

    sanjay_chaturvedi

      Hi,

       

      I have a virtual proc to call a REST service, I successfully ran it in REST UI with header application/json as content type.

      In virtual proc I am passing headers value, but still in logs it is sending header as default i.e.

      [org.apache.cxf.transport.http.Headers] (Worker19_QueryProcessorQueue53) Content-Type: text/xml; charset=utf-8

      while in call, I am passing as application/json.

       

      I have tried following :

      changed headers to IN / INOUT parameter(by default it was out) pls confirm, if this is correct ?

       

      [org.apache.cxf.transport.http.Headers] (Worker19_QueryProcessorQueue53) Content-Type: text/xml; charset=utf-8

       

      EXEC invokeHttp(action => 'PUT', request => JSONOBJECT('{"select":{"from":["Country"]}}'),

      endpoint => 'http://y',

      headers=>'{"content-type":"application\/json;charset=UTF-8","accept":"application\/json"}',

      ContentType=>'application\/json',

      stream => TRUE) ;

       

      also tried giving

      headers=>'{"content-type":"application\/json;charset=UTF-8","accept":"application\/json"}',

      headers => JSONOBJECT('application/json' AS "Content-Type")

       

      but every time it is sending text/html as content type  which is resulting in 415 unsuppotred media type error.  Please suggest

       

      Thanks.

        • 1. Re: HTTP header is not set in invokeHTTP
          rareddy
          • 2. Re: HTTP header is not set in invokeHTTP
            sanjay_chaturvedi

            Thanks Ramesh, but I had already visited that link.

            That was the issue for authorization token while in my case authorization token is passed  but not the content type header. authorization is set in standalone.xml as  resourceadapter  as AuthUserName. But Content-Type , I am passing as invokeHTTP parameter. See below the screen shot I made two changes in generated invokeHttp :1 : made headers as IN parameter and 2. set default value as {Content-Type:application/json}

             

             

             

            I am also attaching TEST.vdb, I manually tried to edit vdb to ensure that there is no quote related issue(like in that post).

            I tried following combinations to ensure that this header is passed but no luck, surprisingly rest of the params are passed :

             

            Here is logs:

            Address: <URL>

            Http-Method: PUT

            Content-Type: text/xml; charset=utf-8

            Headers: {User-Agent=[Teiid Server], Content-Type=[text/xml; charset=utf-8], Authorization=[AUTHTOKEN], Accept=[*/*]}

            Payload: {"expr1":"{\"select\":{\"from\":[\"TABLE\"]}}"}

             

            here is query I tried:

             

             

            EXEC TalendSrc.invokeHttp(action => 'PUT', request => jsonobject('{"select":{"from":["TABLE"]}}'),endpoint=>URI,Strea=>TRUE,

            headers => JSONOBJECT('application/json' AS "Content-Type"))

            Other combinations :

            --'{"Content-Type":"application/json","Accepts":"application/json"}'

             

            --'{"\"Content-Type\"":"application/json","\"Accepts\"":"application/json"}'

             

            Please assist. Thanks.

            • 3. Re: HTTP header is not set in invokeHTTP
              rareddy

              I do not believe the default value for the clob is checked for the value. I suggest you provide that explicitly in your SQL query that is using the invokeHTTP.  I can not open .VDB file and check contents without going through somewhat lengthy conversion (for me) if you can show the XML/DDL version that would save me time


              Ramesh..

              • 4. Re: HTTP header is not set in invokeHTTP
                sanjay_chaturvedi

                Thanks for looking into this. Well, this VDB is not long though, as i created this for you only It has limited meaning ful information contained in two Files : TalendSrc.xmi and vdb.xml.

                TalendSrc.xmi itself contains "only one" virtual proc invokeHTTP. Attaching both the files.

                • 5. Re: HTTP header is not set in invokeHTTP
                  rareddy

                  Sanjay,

                   

                  What I was looking for is XML/DDL version of the VDB not crack open the .vdb and give me the individual files. Can you generate the XML/DDL version using Designer on the VDB Management editor.

                   

                  Ramesh..

                  • 6. Re: HTTP header is not set in invokeHTTP
                    rptmat57

                    I just tried this:

                     

                    headers => '{"Content-Type":"application/json","Accepts":"application/json"}'

                    and it worked fine

                    • 7. Re: HTTP header is not set in invokeHTTP
                      rptmat57

                      I might be wrong, but it seems maybe you are trying to do this in the wrong place.

                      you are editing the invokehttp source file, whereas I think the headers go in the transformation procedure (from invokehttp to your view model)