2

I wanted to get the json data from the gitlab application after I sent request the message and get the payload data(json) I attached the contents using the postman chrome plugin.

I got the error like the followings.

Caused by: java.lang.IllegalArgumentException: Could not resolve 'json__TypeId__' in 'javaTypes'.
    at org.springframework.integration.support.json.AbstractJacksonJsonObjectMapper.createJavaType(AbstractJacksonJsonObjectMapper.java:67)
    at org.springframework.integration.support.json.Jackson2JsonObjectMapper.extractJavaType(Jackson2JsonObjectMapper.java:119)
    at org.springframework.integration.support.json.Jackson2JsonObjectMapper.extractJavaType(Jackson2JsonObjectMapper.java:44)

Header Contents

Cache-Control → max-age=0, private, must-revalidate
Connection → keep-alive
Content-Length → 7744
Content-Type → application/json
Date → Thu, 25 Jun 2015 05:50:04 GMT
ETag → "bf03cd61784161d9550b5924f29559f0"
Link → <http://70.121.224.25/gitlab/api/v3/users?page=2&per_page=0>; rel="next", <http://70.121.224.25/gitlab/api/v3/users?page=1&per_page=0>; rel="first", <http://70.121.224.25/gitlab/api/v3/users?page=20&per_page=0>; rel="last"
Server → nginx
Status → 200 OK
X-Request-Id → a7aced18-64aa-4932-94c0-779270b637d5
X-Runtime → 0.121132

Body Contetns

[
    {
        "name": "alm",
        "username": "alm",
        "id": 2,
        "state": "active",
        "avatar_url": null,
        "created_at": "2014-12-08T17:41:47.000+09:00",
        "is_admin": true,
        "bio": null,
        "skype": "",
        "linkedin": "",
        "twitter": "",
        "website_url": "",
        "email": "alm-support@samsung.com",
        "theme_id": 2,
        "color_scheme_id": 1,
        "extern_uid": null,
        "provider": null,
        "projects_limit": 100,
        "can_create_group": true,
        "can_create_project": true
    },
    {
        "name": "ROOT",
        "username": "ROOT",
        "id": 40,
        "state": "active",
        "avatar_url": null,
        "created_at": "2014-12-17T14:40:52.000+09:00",
        "is_admin": true,
        "bio": null,
        "skype": "",
        "linkedin": "",
        "twitter": "",
        "website_url": "",
        "email": "root@alm.com",
        "theme_id": 2,
        "color_scheme_id": 1,
        "extern_uid": null,
        "provider": null,
        "projects_limit": 100,
        "can_create_group": false,
        "can_create_project": true
    },
    {
    ....

My spring integration program is like the followings. I referneced the link . I have no header values in the header I received from the header.

<int-http:outbound-gateway 
        id="http-outbound-gateway"
        auto-startup="true" 
        http-method="GET" 
        charset="UTF-8"
        request-channel="redca-gitlab-request-prepare-channel"
        reply-channel="redca-hub-gitlab-response-channel"
        url="{gitlab.url}{gitlab.data.type}?private_token={gitlab.private.token}">
         <int-http:uri-variable name="gitlab.url" expression="headers['gitlab.url']"/>  
         <int-http:uri-variable name="gitlab.data.type" expression="headers['gitlab.data.type']"/>
         <int-http:uri-variable name="gitlab.private.token" expression="headers['gitlab.private.token']"/>
    </int-http:outbound-gateway> 

    <int:chain input-channel="redca-hub-gitlab-response-channel"  output-channel="redca-output-channel">
        <int:header-enricher>
            <int:header name="json__TypeId__" expression="headers['x-json__TypeId__']" />
        </int:header-enricher>
        <int:json-to-object-transformer object-mapper="mapper"></int:json-to-object-transformer>
    </int:chain>



    <bean id="mapper" class="org.springframework.integration.support.json.Jackson2JsonObjectMapper">
</bean>
Community
  • 1
  • 1
verystrongjoe
  • 3,831
  • 9
  • 35
  • 66

1 Answers1

0

I don't see an x-json__TypeId__ header - the linked question is about talking to a Spring Integration HTTP server and conveying headers, not about talking to some external HTTP service.

Since you have no headers, you need to tell the <json-to-object-converter/> what you want the object converted to.

<json-to-object-converter type="java.util.HashMap" />

(Or some domain object if you have set up jackson mapping).

Gary Russell
  • 166,535
  • 14
  • 146
  • 179