-
1. Re: how the Rest War can return json
lv_levi Dec 28, 2015 5:10 AM (in response to lv_levi)BTW, I add the Transformation SQl just like this:
"BEGIN
SELECT XMLELEMENT(NAME v_person, XMLAGG(XMLELEMENT(NAME v_person, XMLFOREST(PDSViewMdl.v_person.person_id, PDSViewMdl.v_person.name, PDSViewMdl.v_person.mobile)))) AS result FROM PDSViewMdl.v_person WHERE PDSViewMdl.v_person.person_id = PDSViewMdl.getPerson.person_id;
END"
how can I add the ContentType=application/json into the up SQL.
levi
thanks.
-
2. Re: how the Rest War can return json
shawkins Dec 29, 2015 3:46 PM (in response to lv_levi)With just the standard REST logic there is no automatic conversion to JSON. You can change your procedure to use the json function instead - JSON Functions - Teiid 9.0 (draft) - Project Documentation Editor
If you use an OData instead, then the client can choose between JSON and XML/Atom.
-
3. Re: how the Rest War can return json
lv_levi Dec 30, 2015 4:15 AM (in response to shawkins)hi Steven,
My problems is how to change the procedure to use json function instead. I try using this just like:
BEGIN
SELECT XMLELEMENT(NAME v_project, XMLAGG(XMLELEMENT(NAME v_project, XMLFOREST(restProject.v_project.name, restProject.v_project.pid, restProject.v_project.project_code)))) AS result FROM (EXEC invokeHttp(action => 'GET', endpoint => 'http://localhost:8080/projectvdb/restProject/get', headers => JSONOBJECT('application/json' as "Content-Type"))) AS f, restProject.v_project WHERE restProject.v_project.pid = restProject.getPersonBypid.pid;
END
the jsonobject is not work here, some json funciton did i missed? BTW,I did not use the OData.
levi
thanks
-
4. Re: how the Rest War can return json
shawkins Jan 3, 2016 10:25 AM (in response to lv_levi)> the jsonobject is not work here, some json funciton did i missed? BTW,I did not use the OData.
It looks like from the above you are wanting the invokeHttp call to return json, but are still using xml processing on the json. Do you need the Teiid procedure to return xml or json, and do you want the invokeHttp call to return xml or json?
-
5. Re: how the Rest War can return json
tejones Jan 3, 2016 5:22 PM (in response to lv_levi)Hi Levi,
You can use the Teiid Designer generated REST war to do this which exposes both XML and JSON operations. Have look at Teiid Designer User Guide.
Thanks,
Ted
-
6. Re: how the Rest War can return json
lv_levi Jan 4, 2016 2:52 AM (in response to tejones)1 of 1 people found this helpfulhi Ted,
I add the json beween Modle and get of my visit url,it's returns the json fomart info. thanks you Ted.
Thanks,
Levi
-
7. Re: how the Rest War can return json
lv_levi Jan 4, 2016 3:06 AM (in response to shawkins)hi Steven,
I add the json to the vistit url fllows the TD user Guide which can resolve my problems. thanks for your response!
thanks,
Levi