[MarkLogic Dev General] rest services return xml instead of json

Vinayagam, Jothiprakash (Conduent) Jothiprakash.Vinayagam at conduent.com
Wed Feb 1 16:17:09 PST 2017


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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20170202/eb4437fc/attachment.html 


More information about the General mailing list