wso2 Data Services REST POST JSON format -


i trying (real hard) make data service in wso2 ei611 can call in json. have no idea of json format use when post data service. tried lot of format null error.

thanks in advance.

here data service code :

<data name="oauthtoken" servicegroup="" servicenamespace="">         <description/>         <config id="qt_db">         <property name="org.wso2.ws.dataservice.user">wso2</property>         <property name="org.wso2.ws.dataservice.password">wso2</property>         <property name="org.wso2.ws.dataservice.protocol">jdbc:mysql://192.168.1.10:3306/qt_db</property>         <property name="org.wso2.ws.dataservice.driver">com.mysql.jdbc.driver</property>         </config>         <query id="addnewtoken" useconfig="qt_db">         <sql>insert qt_db.oauth_token (access_token, token_type, api_server, created, expires_in, expiration, refresh_token) values(:access_token, :token_type, :api_server, :created, :expires_in, date_add(:created, interval :expires_in second), :refresh_token);      </sql>         <param name="access_token" sqltype="string" type="in"/>         <param name="token_type" sqltype="string" type="in"/>         <param name="api_server" sqltype="string" type="in"/>         <param name="created" sqltype="timestamp" type="in"/>         <param name="expires_in" sqltype="integer" type="in"/>         <param defaultvalue="0" name="expiration" sqltype="integer" type="in"/>         <param name="refresh_token" sqltype="string" type="in"/>         </query>         <query id="getlasttoken" useconfig="qt_db">         <sql>select created,access_token, token_type, api_server, expires_in, expiration, refresh_token oauth_token created = (select max(created) oauth_token);</sql>         <result defaultnamespace="" element="oauth_tokens" rowname="oauth_token">             <element column="access_token" name="access_token" xsdtype="xs:string"/>             <element column="token_type" name="token_type" xsdtype="xs:string"/>             <element column="api_server" name="api_server" xsdtype="xs:string"/>             <element column="created" name="created" xsdtype="xs:datetime"/>             <element column="expires_in" name="expires_in" xsdtype="xs:integer"/>             <element column="expiration" name="expiration" xsdtype="xs:datetime"/>             <element column="refresh_token" name="refresh_token" xsdtype="xs:string"/>         </result>         </query>         <operation returnrequeststatus="true" name="getlasttoken">         <call-query href="getlasttoken"/>         </operation>         <operation returnrequeststatus="true" name="addnewtoken">         <call-query href="addnewtoken">             <with-param name="access_token" query-param="access_token"/>             <with-param name="token_type" query-param="token_type"/>             <with-param name="api_server" query-param="api_server"/>             <with-param name="created" query-param="created"/>             <with-param name="expires_in" query-param="expires_in"/>             <with-param name="refresh_token" query-param="refresh_token"/>         </call-query>         </operation>         <resource method="get" path="getlasttoken" returnrequeststatus="true">         <call-query href="getlasttoken"/>         </resource>         <resource method="post" path="addnewtoken" returnrequeststatus="true">         <call-query href="addnewtoken">             <with-param name="access_token" query-param="access_token"/>             <with-param name="token_type" query-param="token_type"/>             <with-param name="api_server" query-param="api_server"/>             <with-param name="created" query-param="created"/>             <with-param name="expires_in" query-param="expires_in"/>             <with-param name="refresh_token" query-param="refresh_token"/>         </call-query>         </resource>         <resource method="post" path="addnewtoken2" returnrequeststatus="true">         <call-query href="addtoken">             <with-param name="access_token" query-param="access_token"/>             <with-param name="token_type" query-param="token_type"/>             <with-param name="api_server" query-param="api_server"/>             <with-param name="created" query-param="created"/>             <with-param name="expires_in" query-param="expires_in"/>             <with-param name="expiration" query-param="expiration"/>             <with-param name="refresh_token" query-param="refresh_token"/>         </call-query>         </resource>         <query id="addtoken" useconfig="qt_db">         <sql>insert qt_db.oauth_token (access_token, token_type, api_server, created, expires_in, expiration, refresh_token) values(:access_token, :token_type, :api_server, :created, :expires_in, :expiration, :refresh_token);</sql>         <param name="access_token" sqltype="string" type="in"/>         <param name="token_type" sqltype="string" type="in"/>         <param name="api_server" sqltype="string" type="in"/>         <param name="created" sqltype="timestamp" type="in"/>         <param name="expires_in" sqltype="integer" type="in"/>         <param defaultvalue="0" name="expiration" sqltype="timestamp" type="in"/>         <param name="refresh_token" sqltype="string" type="in"/>         </query>     </data> 

here post try :

{     "addnewtoken2": {         "access_token": "2gql1fo_bhv9gwialgmhf5cuxynfrbhc0",         "token_type": "bearer",         "api_server": "https://api04.iq.questrade.com/",         "created": "2017-09-10t15:05:21.000-04:00",         "expires_in": "1800",         "expiration": "2017-09-10t15:05:21.000-04:00",         "refresh_token": "bz8o65cn9hya2ripbhv9m5q7he65ebls0"     } } 

and error :

[2017-09-10 22:59:07,433] [ei-core] error - serverworker error processing post reguest : /services/oauthtoken.httpendpoint/addnewtoken2. error detail: null.  java.lang.nullpointerexception     @ org.apache.axis2.json.gson.gsonxmlstreamreader.validateargumenttypes(gsonxmlstreamreader.java:783)     @ org.apache.axis2.json.gson.gsonxmlstreamreader.nextvalue(gsonxmlstreamreader.java:734) 

when send post request, request payload should follows.

{     "_postaddnewtoken2": {         "access_token": "2gql1fo_bhv9gwialgmhf5cuxynfrbhc0",         "token_type": "bearer",         "api_server": "https://api04.iq.questrade.com/",         "created": "2017-09-10t15:05:21.000-04:00",         "expires_in": "1800",         "expiration": "2017-09-10t15:05:21.000-04:00",         "refresh_token": "bz8o65cn9hya2ripbhv9m5q7he65ebls0"     } } 

refer https://docs.wso2.com/display/ei611/json+mapping+sample more information


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -