I am glad changing the code to use xdmp.toJSON() worked for you.

Cheers.

-Keith

From: [email protected] 
[mailto:[email protected]] On Behalf Of Vinayagam, 
Jothiprakash (Conduent)
Sent: Friday, February 03, 2017 8:06 AM
To: MarkLogic Developer Discussion <[email protected]>
Subject: Re: [MarkLogic Dev General] rest services return xml instead of json

After modify the  code return as xdmp.toJSON (result) in rest services( this is 
work ground) . it is working fine both local as well as dev. Seems to problem 
with mark logic  version Dev: 8.0-5.8.

From: Vinayagam, Jothiprakash (Conduent)
Sent: Thursday, February 02, 2017 11:39 AM
To: MarkLogic Developer Discussion
Subject: RE: [MarkLogic Dev General] rest services return xml instead of json

Dev: 8.0-5.8
Local: 8.0-6

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Keith Breinholt
Sent: Thursday, February 02, 2017 11:16 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] rest services return xml instead of json

What versions of MarkLogic are your local and dev databases running?

-Keith

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Vinayagam, 
Jothiprakash (Conduent)
Sent: Thursday, February 02, 2017 8:02 AM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] rest services return xml instead of json

I got it. Strange thing here  if I point to local database it returning json 
and if I point to dev database it returning xml. Its wired. Please advise

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Geert Josten
Sent: Thursday, February 02, 2017 3:55 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] rest services return xml instead of json

Hi Jothi,

The outputTypes only influences the Content-type header(s), not causes output 
to get formatted automatically. I recommend making sure you really return a 
JSON object in your REST extension (e.g. object-node() or a true JavaScript 
JSON object), or convert your result to JSON string. You might wanna look into 
xdmp.toJSON, xdmp.toJsonString, json.transformToJson (you need to import the 
xqy module of json:transform-to-json for this), or if working with database 
nodes $mynode.toObject()..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of "Vinayagam, Jothiprakash (Conduent)" 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Thursday, February 2, 2017 at 1:17 AM
To: 
"'[email protected]<mailto:'[email protected]>'" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] rest services return xml instead of json

HI all,

We wrote rest service below to get the data. It returns as xml instead of json

<?xml version="1.0" encoding="UTF-8"?>
<json:array 
xmlns:json="http://marklogic.com/xdmp/json<https://urldefense.proofpoint.com/v2/url?u=http-3A__marklogic.com_xdmp_json&d=DwMFAg&c=z0adcvxXWKG6LAMN6dVEqQ&r=wQ09nIebnRJGH1VgSesPfFnvXo10BKdu-taGZQaoghw&m=6YfTNXqiBQCMGKx4NvaIdYqGMpushI7zY8WXEy9wiYk&s=rXl1EvhK0g2o29NJ7tqvC-UjZWw30qoktvKBw8dJYjg&e=>"
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.w3.org_2001_XMLSchema-2Dinstance&d=DwMFAg&c=z0adcvxXWKG6LAMN6dVEqQ&r=wQ09nIebnRJGH1VgSesPfFnvXo10BKdu-taGZQaoghw&m=6YfTNXqiBQCMGKx4NvaIdYqGMpushI7zY8WXEy9wiYk&s=U0sad5WlcmimVjuTeef2yYqowoFmxuJwgHQh-v1We6w&e=>"
 
xmlns:xs="http://www.w3.org/2001/XMLSchema<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.w3.org_2001_XMLSchema&d=DwMFAg&c=z0adcvxXWKG6LAMN6dVEqQ&r=wQ09nIebnRJGH1VgSesPfFnvXo10BKdu-taGZQaoghw&m=6YfTNXqiBQCMGKx4NvaIdYqGMpushI7zY8WXEy9wiYk&s=C7kO_uQcdpfA6hxbNgvLd4z8DIP3qx1Xn-PZLLjltw8&e=>">
  <json:value><json:object>
      <json:entry key="2017-01">
        <json:value><json:array>
            <json:value><json:object>
               <json:entry key="">
                 <json:value xsi:type="xs:integer">24309</json:value>
               </json:entry>
              </json:object></json:value>
</json:array>



function get(context, params) {
    context.outputTypes = [];
    context.outputTypes.push('application/json');


    var date = (typeof params.fromDate === 'undefined') ? null : 
params.fromDate;
    var endDate = (typeof params.toDate === 'undefined') ? null : params.toDate;
    var doNum = (typeof params.doNum === 'undefined') ? null : params.doNum;
    var ldssID = (typeof params.ldssID === 'undefined') ? null : params.ldssID;
    console.log("testing" + params.fromDate);
    console.log("testing" + params.toDate);


// some code


}



Rest service called from controller:

            MLRest.extension('abawdDashboard', {
                method: 'GET',
                params: { 'rs:fromDate': fromDateRunReport, 'rs:toDate': 
toDateRunReport, 'rs:doNum': $scope.dashboard.doID, 'rs:ldssID': 
$scope.dashboard.ldssID }
            }).then(function(response) {
                console.log("run report" + response.data);
                $scope.indexedObjects = response.data;
                $scope.dashBoardData = response.data;
                var curYear = new Date();
                populateCount(fromDateRunReport, toDateRunReport, 
response.data);
                //$rootScope.$emit('rootScope:emit', 'Emit!'); // $rootScope.$on
                //$rootScope.$broadcast('rootScope:broadcast', response.data);
                //$scope.indexedObjects = indexByAttribute(response.data);
            });


Note: same working fine in my local if I deploy dev/test it returning xml 
instead of json

Thanks
Jothi
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to